package com.ymttest.business.service;

import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import jdk.nashorn.internal.codegen.CompilerConstants.Call;
import oracle.net.aso.e;

import org.apache.commons.collections.map.HashedMap;
import org.apache.http.client.ClientProtocolException;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.json.JSONException;
import org.junit.internal.runners.TestMethod;
import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;

import com.google.common.collect.Lists;
import com.google.gson.JsonObject;
import com.shop2cn.iapi.subscription.parameter.ApplyChargeBean;
import com.shop2cn.iapi.subscription.parameter.MchChargeConfigDto;
import com.shop2cn.iapi.subscription.parameter.SetMchChargeConfigBean;
import com.shop2cn.iapi.subscription.service.ApplyChargeCall;
import com.shop2cn.iapi.subscription.service.SetMchChargeConfigCall;
import com.shop2cn.iapi.wxcomponent.parameter.AppStatusEnum;
import com.shop2cn.iapi.wxcomponent.parameter.ChargeStatusEnum;
import com.shop2cn.iapi.wxcomponent.parameter.GetMchAppAllStatusBean;
import com.shop2cn.iapi.wxcomponent.parameter.GetMchAppListBean;
import com.shop2cn.iapi.wxcomponent.parameter.PayChannelStatusEnum;
import com.shop2cn.iapi.wxcomponent.service.GetMchAppAllStatusCall;
import com.shop2cn.iapi.wxcomponent.service.GetMchAppListCall;
import com.ymatou.iapi.activitymanage.service.returnProductActivityStockCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.ymatou.iapi.captcha.parameter.GetValidateCodeBean;
import com.ymatou.iapi.captcha.service.GetValidateCodeCall;
import com.ymatou.iapi.dguser.parameter.CreateUserBackBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.UserCreateCall;
import com.ymatou.iapi.dguser.testcase.Ts_UserCreate;
import com.ymatou.iapi.godmch.parameter.AddAfterServiceInfoBean;
import com.ymatou.iapi.godmch.parameter.GetEffectExchangeRateBean;
import com.ymatou.iapi.godmch.parameter.MchInfoVo;
import com.ymatou.iapi.godmch.parameter.PercentageItem;
import com.ymatou.iapi.godmch.parameter.PointConfig;
import com.ymatou.iapi.godmch.parameter.SetPayModeBean;
import com.ymatou.iapi.godmch.parameter.addPointBean;
import com.ymatou.iapi.godmch.parameter.addProviderBean;
import com.ymatou.iapi.godmch.parameter.addServiceRelationBean;
import com.ymatou.iapi.godmch.parameter.adminBindAgentBean;
import com.ymatou.iapi.godmch.parameter.applyAgentBean;
import com.ymatou.iapi.godmch.parameter.applySupplierBean;
import com.ymatou.iapi.godmch.parameter.approveAgentBean;
import com.ymatou.iapi.godmch.parameter.approveSupplierBean;
import com.ymatou.iapi.godmch.parameter.authShopDesignBean;
import com.ymatou.iapi.godmch.parameter.bindRelationBean;
import com.ymatou.iapi.godmch.parameter.bindmchBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.DeleteMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.GetMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.cancelAuthShopDesignBean;
import com.ymatou.iapi.godmch.parameter.condition;
import com.ymatou.iapi.godmch.parameter.createCSBean;
import com.ymatou.iapi.godmch.parameter.createDepotBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createSupplierCodeBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.deleteSupplierBean;
import com.ymatou.iapi.godmch.parameter.detailmchBean;
import com.ymatou.iapi.godmch.parameter.editRemarkCSBean;
import com.ymatou.iapi.godmch.parameter.editRemarkagentBean;
import com.ymatou.iapi.godmch.parameter.editSupplierBean;
import com.ymatou.iapi.godmch.parameter.editTypeagentBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getAgentPromotePicBean;
import com.ymatou.iapi.godmch.parameter.getChannelPicBean;
import com.ymatou.iapi.godmch.parameter.getChargeConfigBean;
import com.ymatou.iapi.godmch.parameter.getInviteCpsPicBean;
import com.ymatou.iapi.godmch.parameter.getInviteDistributorOrganizationPicBean;
import com.ymatou.iapi.godmch.parameter.getInviteDistributorPicBean;
import com.ymatou.iapi.godmch.parameter.getMchListByIdListBean;
import com.ymatou.iapi.godmch.parameter.getProviderByIdBean;
import com.ymatou.iapi.godmch.parameter.listagentTypeBean;
import com.ymatou.iapi.godmch.parameter.RemoveCodeBean;
import com.ymatou.iapi.godmch.parameter.SetMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.mchCreateCsBean;
import com.ymatou.iapi.godmch.parameter.reApplyAgentBean;
import com.ymatou.iapi.godmch.parameter.reApplySupplierBean;
import com.ymatou.iapi.godmch.parameter.registerBean;
import com.ymatou.iapi.godmch.parameter.registerByCodeBean;
import com.ymatou.iapi.godmch.parameter.rejectAgentBean;
import com.ymatou.iapi.godmch.parameter.rejectSupplierBean;
import com.ymatou.iapi.godmch.parameter.removeCSBean;
import com.ymatou.iapi.godmch.parameter.removeagentBean;
import com.ymatou.iapi.godmch.parameter.removemchBean;
import com.ymatou.iapi.godmch.parameter.setAgentConditionLevelBean;
import com.ymatou.iapi.godmch.parameter.setAgentConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.setAgentMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.setBizConfigBean;
import com.ymatou.iapi.godmch.parameter.setBuyerCsBean;
import com.ymatou.iapi.godmch.parameter.setChargeConfigBean;
import com.ymatou.iapi.godmch.parameter.setConditionLevelBean;
import com.ymatou.iapi.godmch.parameter.setConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.setInteractionStateBean;
import com.ymatou.iapi.godmch.parameter.setMarketPriceConfigBean;
import com.ymatou.iapi.godmch.parameter.SetMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.setMchAllConfigBean;
import com.ymatou.iapi.godmch.parameter.setPointConfigBean;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymatou.iapi.godmch.parameter.setWaterMarkBean;
import com.ymatou.iapi.godmch.parameter.updateAgentConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.updateConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.service.AddAfterServiceInfoCall;
import com.ymatou.iapi.godmch.service.GetEffectExchangeRateCall;
import com.ymatou.iapi.godmch.service.SetPayModeCall;
import com.ymatou.iapi.godmch.service.addPointCall;
import com.ymatou.iapi.godmch.service.addProviderCall;
import com.ymatou.iapi.godmch.service.addServiceRelationCall;
import com.ymatou.iapi.godmch.service.adminBindAgentCall;
import com.ymatou.iapi.godmch.service.applyAgentCall;
import com.ymatou.iapi.godmch.service.applySupplierCall;
import com.ymatou.iapi.godmch.service.approveAgentCall;
import com.ymatou.iapi.godmch.service.approveSupplierCall;
import com.ymatou.iapi.godmch.service.authShopDesignCall;
import com.ymatou.iapi.godmch.service.bindRelationCall;
import com.ymatou.iapi.godmch.service.bindmchCall;
import com.ymatou.iapi.godmch.service.cancelAuthShopDesignCall;
import com.ymatou.iapi.godmch.service.createCSCall;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.DeleteMarkupConfigCall;
import com.ymatou.iapi.godmch.service.GetMarkupConfigCall;
import com.ymatou.iapi.godmch.service.createDepotCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createSupplierCodeCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.godmch.service.createmchCall;
import com.ymatou.iapi.godmch.service.deleteSupplierCall;
import com.ymatou.iapi.godmch.service.detailmchCall;
import com.ymatou.iapi.godmch.service.editDepotCall;
import com.ymatou.iapi.godmch.service.editRemarkCSCall;
import com.ymatou.iapi.godmch.service.editRemarkagentCall;
import com.ymatou.iapi.godmch.service.editSupplierCall;
import com.ymatou.iapi.godmch.service.editTypeagentCall;
import com.ymatou.iapi.godmch.service.editmchCall;
import com.ymatou.iapi.godmch.service.getAgentPromotePicCall;
import com.ymatou.iapi.godmch.service.getChannelPicCall;
import com.ymatou.iapi.godmch.service.getInviteCpsPicCall;
import com.ymatou.iapi.godmch.service.getInviteDistributorOrganizationPicCall;
import com.ymatou.iapi.godmch.service.getInviteDistributorPicCall;
import com.ymatou.iapi.godmch.service.getMchListByIdListCall;
import com.ymatou.iapi.godmch.service.getProviderByIdCall;
import com.ymatou.iapi.godmch.service.listagentTypeCall;
import com.ymatou.iapi.godmch.service.mchCreateCsCall;
import com.ymatou.iapi.godmch.service.reApplyAgentCall;
import com.ymatou.iapi.godmch.service.reApplySupplierCall;
import com.ymatou.iapi.godmch.service.registerByCodeCall;
import com.ymatou.iapi.godmch.service.registerCall;
import com.ymatou.iapi.godmch.service.rejectAgentCall;
import com.ymatou.iapi.godmch.service.rejectSupplierCall;
import com.ymatou.iapi.godmch.service.removeCSCall;
import com.ymatou.iapi.godmch.service.removeagentCall;
import com.ymatou.iapi.godmch.service.RemoveCodeCall;
import com.ymatou.iapi.godmch.service.SetMarkupConfigCall;
import com.ymatou.iapi.godmch.service.removemchCall;
import com.ymatou.iapi.godmch.service.setAgentConditionLevelCall;
import com.ymatou.iapi.godmch.service.setAgentConditionMarkupConfigCall;
import com.ymatou.iapi.godmch.service.setAgentMarkupConfigCall;
import com.ymatou.iapi.godmch.service.setBizConfigCall;
import com.ymatou.iapi.godmch.service.setBuyerCsCall;
import com.ymatou.iapi.godmch.service.setChargeConfigCall;
import com.ymatou.iapi.godmch.service.setConditionLevelCall;
import com.ymatou.iapi.godmch.service.setConditionMarkupConfigCall;
import com.ymatou.iapi.godmch.service.setInteractionStateCall;
import com.ymatou.iapi.godmch.service.setMarketPriceConfigCall;
import com.ymatou.iapi.godmch.service.SetMarkupConfigCall;
import com.ymatou.iapi.godmch.service.setMchAllConfigCall;
import com.ymatou.iapi.godmch.service.setPointConfigCall;
import com.ymatou.iapi.godmch.service.setShareTypeCall;
import com.ymatou.iapi.godmch.service.setWaterMarkCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymttest.business.service.shenqi.SqDistributorService;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.godmch.interactionstate;
import com.ymttest.database.model.godmch.mch_config;
import com.ymttest.database.model.godmch.mch_configExample;
import com.ymttest.database.model.godmch.mch_depot_info;
import com.ymttest.database.model.godmch.mch_depot_infoExample;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.database.sqlwapper.godmch.agent_typeWapper;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
import com.ymttest.database.sqlwapper.godmch.mch_configWapper;
import com.ymttest.database.sqlwapper.godmch.mch_depot_infoWapper;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

public class GodmchManageCallService {

	public static agent_typeWapper agentTypeWapper = new agent_typeWapper();
	public static mch_infoWapper mchinfoWapper = new mch_infoWapper();
	public static mch_configWapper mchconfigWapper = new mch_configWapper();
	public static final List<Integer> ALLPermissionList = Arrays.asList(101, 102, 103, 104, 105, 201, 202, 203, 204);
	public static final List<Integer> ALLRolesList = Arrays.asList(1, 2, 3, 4);
	public static final Integer agent_promote_mchId=Integer.parseInt(EnvSetup.getData("agent_promote_mchId"));

	/**
	 * 代理用户
	 * 
	 * @return
	 * @throws Exception
	 */
	public static int UserCreateAgent() throws Exception {
		UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
		usercreateBean.setIscs(false);
		usercreateBean.setMobile(TestDataManager.getPhoneNum());
		usercreateBean.setMobileAreaCode("86");
		usercreateBean.setUserType(1);
		usercreateBean.setAppSource(DGUserCallService.DG_SellerWxApp);
		usercreateBean.setWxAppName(DGUserCallService.TestWxsqSeller);
		int userId = DGUserCallService.UserCreateCall(usercreateBean);
		return userId;
	}

	/**
	 * 商家付费订购套餐
	 * 
	 * 一年直播：0 3 一年线下付款 4 5
	 * 
	 * @param mchId
	 * @param funcType
	 * @param funcPackageId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static JsonObject ApplyCharge(int mchId, int funcType, int funcPackageId)
			throws ClientProtocolException, IOException {
		ApplyChargeBean applychargeBean = new ApplyChargeBean();
		ApplyChargeCall applychargeCall = new ApplyChargeCall();
		applychargeBean.setMchId(mchId);
		applychargeBean.setFuncType(funcType);
		applychargeBean.setFuncPackageId(funcPackageId);
		applychargeBean.setCallbackUrl("http://www.ymatou.com");
		applychargeBean.setClientIp(TestDataManager.getRandomIp());
		applychargeCall.setData(applychargeBean);
		applychargeCall.callService();
		Logger.verifyEquals("200", applychargeCall.getString("code"), "验证code");
		return applychargeCall.getJsonObject();
	}

	/**
	 * 根据商户id 获取 代理类型列表bean
	 * 
	 * @param mchId
	 * @return
	 */
	public static listagentTypeBean InitlistgentTypeBean(int mchId) {
		listagentTypeBean bean = new listagentTypeBean();
		bean.setMchId(mchId);
		return bean;
	}

	/**
	 * 传入功能列表，增加白名单或者删除白名单
	 * 
	 * @param mchId
	 * @param funcs
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static void SetTrueMchChargeConfig(Integer mchId, List<Integer> funcs, boolean charge)
			throws ClientProtocolException, IOException {
		List<Integer> asList = Arrays.asList(0, 1, 2, 3, 4);
		SetMchChargeConfigBean setmchchargeconfigBean = new SetMchChargeConfigBean();
		SetMchChargeConfigCall setmchchargeconfigCall = new SetMchChargeConfigCall();
		setmchchargeconfigBean.setMchId(mchId);
		List<MchChargeConfigDto> mchChargeConfigList = new ArrayList<>();
		if (asList != null) {
			for (int i = 0; i < asList.size(); i++) {
				Integer b = asList.get(i);
				MchChargeConfigDto mchChargeConfigDto = new MchChargeConfigDto();
				mchChargeConfigDto.setFuncTypeId(b);
				mchChargeConfigDto.setCharge(funcs.contains(b) ? charge : !charge);
				mchChargeConfigList.add(mchChargeConfigDto);
			}
		}
		setmchchargeconfigBean.setMchChargeConfigList(mchChargeConfigList);
		setmchchargeconfigCall.setData(setmchchargeconfigBean);
		setmchchargeconfigCall.callService();
		Logger.verifyEquals("200", setmchchargeconfigCall.getString("code"), "验证code");

	}

	/**
	 * 根据商户id 获取 代理类型列表 call
	 * 
	 * @param mchId
	 * @return
	 */
	public static listagentTypeCall listgentTypeCall(listagentTypeBean bean)
			throws ClientProtocolException, IOException {
		listagentTypeCall call = new listagentTypeCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 创建代理bean-上海代理 北京代理
	 * 
	 * @param mchId
	 * @return
	 */
	public static createagentBean InitCreateAgentTypeBean(int mchId) {
		createagentBean createagentBean = new createagentBean();
		createagentBean.setMchId(mchId);
		createagentBean.setTitle("自动化测试_" + TestDataManager.getRandomIntNum(5));
		createagentBean.setRemark("自动化测试代理备注备注_" + TestDataManager.getRandomIntNum(5));
		createagentBean.setNickName("自动化测试昵称昵称_" + TestDataManager.getRandomIntNum(5));
		return createagentBean;
	}

	/**
	 * 创建代理Call-上海代理 北京代理
	 * 
	 * @param createagentBean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static createagentCall CreateAgentTypeCall(createagentBean createagentBean)
			throws ClientProtocolException, IOException {
		createagentCall createagentCall = new createagentCall();
		createagentCall.setData(false, createagentBean);
		createagentCall.callService();
		return createagentCall;
	}

	/**
	 * 给mchId新增代理类型titile
	 * 
	 * @param mchId
	 * @param titile
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static createagentCall CreateagentCall(int mchId, String titile)
			throws ClientProtocolException, IOException {
		createagentBean createagentBean = new createagentBean();
		createagentBean.setMchId(mchId);
		createagentBean.setTitle(titile);
		createagentBean.setRemark(titile + "_remark");
		createagentBean.setNickName("nick" + TestDataManager.getRandomIntNum(5));
		createagentCall createagentCall = new createagentCall();
		createagentCall.setData(false, createagentBean);
		createagentCall.callService();
		return createagentCall;
	}

	/**
	 * 创建代理邀请码 bean mchId:商户id isPermanently:若不传是永久,传根据传的值来决定
	 * 
	 * @param mchId
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 * @throws InterruptedException
	 */
	public static CreateCodeBean InitcreateCodeBeanForAgent(int mchId, boolean... isPermanently)
			throws ClientProtocolException, IOException, InterruptedException {

		// 修改商户title和图像
		editmchBean editmchBean = GodmchManageCallService.IniteditmachBean(mchId);
		GodmchManageCallService.editmachCall(editmchBean);

		CreateCodeBean bean = new CreateCodeBean();
		bean.setMchId(mchId);
		bean.setCodeRole(1);

		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", mchId);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		if (agenttypeList.size() < 3) {
			// 创建代理类型
			createagentBean createagentBean = InitCreateAgentTypeBean(mchId);
			createagentCall createagentcall = CreateAgentTypeCall(createagentBean);
		}
		List<agent_type> list = agentTypeWapper.selectby(map);
		bean.setRoleType(list.get(0).getAgentType());// 代理类型(如：北京代理，上海代理)
		if (isPermanently.length > 0)
			bean.setIsPermanently(isPermanently[0]);
		else
			bean.setIsPermanently(true);
		
	
		return bean;
	}

	/**
	 * 为分销小店创建代理邀请码 bean mchId:商户id isPermanently:若不传是永久,传根据传的值来决定
	 * 
	 * @param mchId
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 * @throws InterruptedException
	 */
	public static CreateCodeBean InitcreateCodeBeanForRetailShopAgent(int mchId, BigDecimal rebateRate,
			boolean... isPermanently) throws ClientProtocolException, IOException, InterruptedException {
		// 设置商户信息（头像、名称、微信号）
		editmchBean editmchbean = GodmchManageCallService.IniteditmachBean(mchId);
		GodmchManageCallService.editmachCall(editmchbean);

		CreateCodeBean bean = new CreateCodeBean();
		bean.setMchId(mchId);
		bean.setCodeRole(1);

		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap<>();
		map.put("mchId", mchId);
		map.put("agentMode", 2);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		if (agenttypeList.size() < 3) {
			// 创建代理类型
			createagentBean createagentBean = InitCreateAgentTypeBean(mchId);

			createagentBean.setAgentMode(2);
			createagentBean.setRebateRate(rebateRate);

			CreateAgentTypeCall(createagentBean);
		}
		List<agent_type> list = agentTypeWapper.selectby(map);
		bean.setRoleType(list.get(0).getAgentType());// 代理类型(如：北京代理，上海代理)
		if (isPermanently.length > 0)
			bean.setIsPermanently(isPermanently[0]);
		else
			bean.setIsPermanently(true);
		return bean;
	}

	/**
	 * 创建客服邀请码 bean
	 * 
	 * @param mchId
	 * @param roleType 1-4
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static CreateCodeBean InitcreateCodeBeanForCustom(int mchId, int roleType)
			throws ClientProtocolException, IOException {
		CreateCodeBean bean = new CreateCodeBean();
		bean.setMchId(mchId);
		bean.setCodeRole(2);
		bean.setRoleType(roleType);
		bean.setIsPermanently(true);
		return bean;
	}

	/**
	 * 创建代理邀请码 call
	 * 
	 * @param mchId 吗
	 * @return
	 */
	public static CreateCodeCall createCodeCall(CreateCodeBean bean) throws ClientProtocolException, IOException {
		CreateCodeCall call = new CreateCodeCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 创建渠道商bean agent
	 * 
	 * @param mchId
	 * @return
	 * @throws Exception
	 */
	public static createmchBean InitcreatemchBeanForChannel(int... mchId) throws Exception {
		createmchBean bean = new createmchBean();
		if (mchId.length > 0)
			bean.setMchId(mchId[0]);
		else {
			UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(usercreateBean);
			bean.setMchId(userId);
		}
		bean.setNickName("自动化测试ww渠道有下级");
		bean.setCountry("USA");
		return bean;
	}

	/**
	 * 根据渠道id 创建 代理ID
	 * 
	 * @param mchId   渠道ID
	 * @param agentId 代理id
	 * @return
	 * @throws Exception
	 */
	public static createmchBean InitcreatemchBeanForAgent2(int mchId, int... agentId) throws Exception {
		createmchBean bean = new createmchBean();
		if (agentId.length > 0)
			bean.setMchId(agentId[0]);
		else {
			UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(usercreateBean);
			bean.setMchId(userId);
		}
		bean.setNickName("自动化测试");
		bean.setCountry("USA");
		return bean;
	}

	/**
	 * 创建渠道商 call
	 * 
	 * @param mchId
	 * @return
	 */
	public static createmchCall createmchCallForChannel(createmchBean bean)
			throws ClientProtocolException, IOException {
		createmchCall call = new createmchCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/***
	 * 移除绑定关系
	 * 
	 * @param mchId       渠道
	 * @param unbindMchId 被移除的代理
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static removemchCall InitremovemchForAgent(int mchId, int unbindMchId)
			throws ClientProtocolException, IOException {
		removemchBean bean = new removemchBean();
		removemchCall call = new removemchCall();
		bean.setMchId(mchId);
		bean.setUnbindMchId(unbindMchId);
		bean.setRemark("移除绑定关系");
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 创建代理bean agent 创建一个渠道 一个代理商
	 * 
	 * @param mchId   自己的用户id
	 * @param agentId 下级的用户id
	 * @return
	 * @throws Exception
	 */
	public static List<createmchBean> InitcreatemchBeanForAgent(int mchId, int... agentId) throws Exception {
		// 1:创建用户
		createmchBean bean = new createmchBean();
		List<createmchBean> beanList = new ArrayList();
		UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();

		int userId_channl = 0;
		if (mchId != 0) {
			userId_channl = mchId;
		} else {
			userId_channl = DGUserCallService.UserCreateCall(usercreateBean);
			// 2：创建渠道商
			createmchBean createmchBean = InitcreatemchBeanForChannel(userId_channl);
			createmchCallForChannel(createmchBean);
		}

		invite_codeWapper invitecodeWapper = new invite_codeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", userId_channl);
		map.put("isPermanently", true);
		List<invite_code> codeList = invitecodeWapper.selectby(map);
		if (codeList.size() == 0) {
			// 3:渠道商 创建邀请码 //4:代理类型(如：北京代理，上海代理)
			CreateCodeBean createCodeBean = InitcreateCodeBeanForAgent(userId_channl);
			CreateCodeCall createCall = createCodeCall(createCodeBean);
		}
		// 需要获取token有延时
		Thread.sleep(100);
		codeList = invitecodeWapper.selectby(map);
		// 5:创建代理 使用 渠道商邀请码、代理类型
		// 设置商户信息（头像、名称、微信号）
		editmchBean editmchbean = GodmchManageCallService.IniteditmachBean(userId_channl);
		GodmchManageCallService.editmachCall(editmchbean);

		createmchBean createmchBean_agent = new createmchBean();
		int userId2 = 0;
		int[] userId_agentIds = null;
		if (agentId.length > 0) {
			userId_agentIds = agentId;
			for (int a : userId_agentIds) {
				createmchBean_agent = new createmchBean();
				createmchBean_agent.setMchId(a);
				createmchBean_agent.setCode(codeList.get(0).getInviteCode());
				createmchBean_agent.setCountry("USA");
				createmchBean_agent.setNickName("自动化测试ww代理1");
				beanList.add(createmchBean_agent);

			}
		} else {
			usercreateBean = DGUserCallService.initUsercreateBean();
			userId2 = DGUserCallService.UserCreateCall(usercreateBean);
			createmchBean_agent.setMchId(userId2);
			createmchBean_agent.setCode(codeList.get(0).getInviteCode());
			createmchBean_agent.setCountry("USA");
			createmchBean_agent.setNickName("自动化测试");
			beanList.add(createmchBean_agent);
		}

		return beanList;
	}

	/**
	 * 创建代理 call
	 * 
	 * @param mchId
	 * @return
	 * @return
	 */
	public static String createmchCallForAgent(createmchBean... bean) throws ClientProtocolException, IOException {
		String status = "";
		for (createmchBean b : bean) {
			// b.setCountry("CHN");
			createmchCall call = new createmchCall();
			call.setData(false, b);
			call.callService();
			status = call.getString("status");
		}
		return status;
	}

	/**
	 * 移除绑定关系
	 * 
	 * @param mchId
	 * @param code
	 * @return
	 */
	public static RemoveCodeBean InitremoveBean(int mchId, String code) {
		RemoveCodeBean bean = new RemoveCodeBean();
		bean.setMchId(mchId);
		bean.setCode(code);
		return bean;
	}

	public static RemoveCodeCall removecall(RemoveCodeBean bean) throws ClientProtocolException, IOException {
		RemoveCodeCall call = new RemoveCodeCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 绑定关系
	 * 
	 * @param mchId
	 * @param code
	 * @return
	 */
	public static bindmchBean InitbindmchBean(int mchId, String code) {
		bindmchBean bean = new bindmchBean();
		bean.setMchId(mchId);
		bean.setCode(code);
		return bean;
	}

	public static bindmchCall bindmchcall(bindmchBean bean) throws ClientProtocolException, IOException {
		bindmchCall call = new bindmchCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 给商家添加客服
	 * 
	 * @param mchId
	 * @param csId
	 * @param templateId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static createCSCall CreateCSCall(Integer mchId, Integer csId, Integer templateId)
			throws ClientProtocolException, IOException {
		createCSBean createcsBean = new createCSBean();
		createcsBean.setCsId(csId);
		createcsBean.setMchId(mchId);
		createcsBean.setTemplateId(templateId);
		createCSCall createcsCall = new createCSCall();
		createcsCall.setData(false, createcsBean);
		createcsCall.callService();
		return createcsCall;
	}

	/**
	 * 客服绑定
	 * 
	 * @param mchId    商户Id
	 * @param template 客服权限：1（基本权限），4（所有权限）
	 * @return
	 * @throws Exception
	 */
	public static int bindClientService(long mchId, int template) {

		int csId = 0;

		try {
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall((int) mchId, csId, template);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Logger.comment("创建渠道商客服:" + csId);

		return csId;
	}

	/**
	 * 设置商户信息（头像、名称、微信号）
	 * 
	 * @param mchId
	 * @return
	 */
	public static editmchBean IniteditmachBean(int mchId) {
		editmchBean bean = new editmchBean();
		bean.setMchId(mchId);
		bean.setMchTitle("修改商户名称_" + TestDataManager.getPhoneNum());
		bean.setAvatar(DGUserCallService.DefImg2);
		bean.setWechat("自动化自动化测试");
		return bean;
	}

	public static editmchCall editmachCall(editmchBean bean) throws ClientProtocolException, IOException {
		editmchCall call = new editmchCall();
		call.setData(false, bean);
		call.callService();
		return call;
	}

	/**
	 * 编辑商户信息
	 * 
	 * @param mchId
	 * @param csId
	 * @param templateId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void editMchInfo(Integer mchId, String title, String avatar, String wechat)
			throws ClientProtocolException, IOException {
		editmchBean bean = new editmchBean();
		editmchCall call = new editmchCall();
		bean.setAvatar(avatar);
		bean.setMchId(mchId);
		bean.setMchTitle(title);
		bean.setWechat(wechat);
		call.setData(bean);
		call.callService();
	}

	/**
	 * 移除客服
	 * 
	 * @param mchId
	 * @param csId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void RemoveCs(Integer mchId, Integer csId) throws ClientProtocolException, IOException {
		removeCSBean removecsBean = new removeCSBean();
		removeCSCall removecsCall = new removeCSCall();
		removecsBean.setCsId(csId);
		removecsBean.setMchId(mchId);
		removecsCall.setData(false, removecsBean);
		removecsCall.callService();
	}

	/**
	 * 修改代理商的代理类型
	 * 
	 * @param mchId     上级商家id
	 * @param agentId   代理商id
	 * @param agentType 代理类型
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void EditAgentType(Integer mchId, Integer agentId, Integer agentType)
			throws ClientProtocolException, IOException {
		editTypeagentBean bean = new editTypeagentBean();
		editTypeagentCall call = new editTypeagentCall();
		bean.setMchId(mchId);
		bean.setAgentId(agentId);
		bean.setAgentType(agentType);
		call.setData(false, bean);
		call.callService();
	}

	/**
	 * 编辑客服的备注
	 * 
	 * @param mchId
	 * @param csId
	 * @param remark
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void EditCsRemark(Integer mchId, Integer csId, String remark)
			throws ClientProtocolException, IOException {
		editRemarkCSBean editremarkcsBean = new editRemarkCSBean();
		editRemarkCSCall editremarkcsCall = new editRemarkCSCall();
		editremarkcsBean.setCsId(csId);
		editremarkcsBean.setMchId(mchId);
		editremarkcsBean.setRemark(remark);
		editremarkcsCall.setData(editremarkcsBean);
		editremarkcsCall.callService();
	}

	/**
	 * 编辑代理商的备注
	 * 
	 * @param mchId
	 * @param agentid
	 * @param remark
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void EditAgentRemark(Integer mchId, Integer agentid, String remark)
			throws ClientProtocolException, IOException {
		editRemarkagentBean bean = new editRemarkagentBean();
		editRemarkagentCall call = new editRemarkagentCall();
		bean.setAgentId(agentid);
		bean.setMchId(mchId);
		bean.setRemark(remark);
		call.setData(bean);
		call.callService();
	}

	/**
	 * 创建一个渠道商-有代理信息-有头像
	 * 
	 * @return 返回mchid
	 * @throws Exception
	 */
	public static Integer CreateSellerMch() throws Exception {
		UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
		int mchId2 = DGUserCallService.UserCreateCall(usercreateBean2);
		createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(mchId2);
		createmchbean2.setNickName(usercreateBean2.getNickname());
		GodmchManageCallService.createmchCallForChannel(createmchbean2);
		Logger.comment("根据用户创建渠道商:" + mchId2);
		return mchId2;
	}

	/**
	 * 创建一个渠道商-有代理信息-有头像-可选国家
	 * 
	 * @return 返回mchid
	 * @throws Exception
	 */
	public static Integer CreateCountrySellerMch(String country) throws Exception {
		UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
		int mchId2 = DGUserCallService.UserCreateCall(usercreateBean2);
		createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(mchId2);
		createmchbean2.setNickName(usercreateBean2.getNickname());
		createmchbean2.setCountry(country);
		GodmchManageCallService.createmchCallForChannel(createmchbean2);
		Logger.comment("根据用户创建渠道商:" + mchId2);
		return mchId2;
	}

	/**
	 * 创建代理商
	 * 
	 * @param code 邀请码
	 * @return
	 * @throws Exception
	 */
	public static Integer CreateSellerMch(String code) throws Exception {
		UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
		int mchId2 = DGUserCallService.UserCreateCall(usercreateBean2);
		createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(mchId2);
		createmchbean2.setNickName(usercreateBean2.getNickname());
		createmchbean2.setCode(code);
		GodmchManageCallService.createmchCallForChannel(createmchbean2);
		Logger.comment("根据用户创建渠道商:" + mchId2);
		return mchId2;
	}

	/**
	 * 根据商户创建分销员
	 * 
	 * @param shopId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static int CreateDistributor(Integer mchId) throws ClientProtocolException, IOException {
		UserCreateBean usercreateBean = new UserCreateBean();
		UserCreateCall usercreateCall = new UserCreateCall();
		usercreateBean = new Ts_UserCreate().initUsercreateBean();
		usercreateBean.setShopId(mchId);
		usercreateBean.setUserType(3);
		usercreateCall.setData(usercreateBean);
		usercreateCall.callService();
		Logger.verifyEquals("true", usercreateCall.getString("success"), "验证success");
		Logger.verifyNotNull(usercreateCall.getString("userId"), "验证uid");
		return usercreateCall.getJsonObject().get("userId").getAsInt();
	}

	/**
	 * 创建一个mchid 用来申请邀请码
	 * 
	 * @return 返回CreateCodeBean 可以直接调用创建邀请码接口
	 * @throws Exception
	 */
	public static CreateCodeBean CreateAllMsgSellerMch() throws Exception {
		UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
		int mchId2 = DGUserCallService.UserCreateCall(usercreateBean2);
		createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(mchId2);
		createmchbean2.setNickName(usercreateBean2.getNickname());
		GodmchManageCallService.createmchCallForChannel(createmchbean2);
		Logger.comment("根据用户创建渠道商:" + mchId2);
		// 头像必要
		editmchBean editmchbean = GodmchManageCallService.IniteditmachBean(mchId2);
		GodmchManageCallService.editmachCall(editmchbean);
		Logger.comment("修改用户信息");
		// 创建一个渠道代理类型id
		createagentBean createagentBean = InitCreateAgentTypeBean(mchId2);
		createagentCall createagentcall = CreateAgentTypeCall(createagentBean);
		Map<String, Object> map = new HashMap();
		map.put("mchId", mchId2);
		List<agent_type> list = agentTypeWapper.selectby(map);
		// codeRole int M 被邀请对象角色 1：代理 2：客服（一期暂无创建邀请码功能）
		// roleType int M codeRole = 1，代理类型id codeRole = 2，客服权限模板id
		CreateCodeBean CreateCodeBean = new CreateCodeBean();
		CreateCodeBean.setMchId(mchId2);
		CreateCodeBean.setIsPermanently(true);
		CreateCodeBean.setCodeRole(1);
		CreateCodeBean.setRoleType(list.get(0).getAgentType());

		return CreateCodeBean;
	}

	/**
	 * 设置商户为vip
	 * 
	 * @param mchId
	 * @throws InterruptedException
	 */
	public static void SetVip(int mchId) throws InterruptedException {
		mch_infoWapper mchInfoWapper = new mch_infoWapper();
		// 设置vip
		Map<String, Object> map = new HashMap();
		map.put("mchId", mchId);
		mch_info mchInfo = mchInfoWapper.selectby(map).get(0);
		mchInfo.setVip(1);
		mchInfoWapper.updateByPrimaryKey(mchInfo);
	}

	/**
	 * 移除商家的指定代理类型
	 * 
	 * @param mchid
	 * @param agentType
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void RemoveAgentType(Integer mchid, Integer agentType) throws ClientProtocolException, IOException {
		removeagentBean bean = new removeagentBean();
		removeagentCall call = new removeagentCall();
		;
		bean.setMchId(mchid);
		bean.setAgentType(agentType);
		call.setData(bean);
		call.callService();
	}

	/**
	 * 获取一个AgentTypeIdList 这个AgentTypeId 是mchId下的且不是AgentType 可以用来快速修改代理商类型case
	 * 
	 * @param mchId
	 * @param AgentType
	 * @return
	 * @throws InterruptedException
	 */
	public static List<Integer> getNotMyAgentType(Integer mchId, Integer AgentType) throws InterruptedException {
		List<Integer> atlist = new DefGodMchWapper().selectAgentType(mchId, null).stream()
				.filter(at -> !at.getAgentType().equals(AgentType)).mapToInt(agent_type::getAgentType).boxed()
				.collect(Collectors.toList());
		return atlist;
	}

	public static setShareTypeBean initsetShareType(int userId_channl, int... mchShareType) throws Exception {
		setShareTypeBean bean = new setShareTypeBean();
		setShareTypeCall call = new setShareTypeCall();
		// 渠道
		if (userId_channl == 0) {
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();// 初始化创建用户
																					// 为什么手机号没有值
			userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);
		}

		createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
		GodmchManageCallService.createmchCallForChannel(createmchbean);
		editmchBean editmchbean = GodmchManageCallService.IniteditmachBean(userId_channl);
		GodmchManageCallService.editmachCall(editmchbean);

		bean.setMchId(userId_channl);
		if (mchShareType.length > 0)
			bean.setMchShareType(mchShareType[0]);
		else
			bean.setMchShareType(1);
		bean.setMchStatus(0);
		bean.setRemark("test");
        bean.setAliPayDomesticPayMode(0);//支付宝国内支付通道 0：不开启 1：盛付通
		call.setData(bean);
		call.callService();
		return bean;
	}

	/**
	 * 商户店铺分享与支付通道合并
	 * 
	 * @param userId_channl
	 * @return
	 * @throws Exception
	 */
	public static setShareTypeBean initsetShareTypeV2(int userId_channl) throws Exception {

		setShareTypeBean bean = new setShareTypeBean();
		setShareTypeCall call = new setShareTypeCall();
		// 渠道
		if (userId_channl == 0) {
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();// 初始化创建用户

			userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);

			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			editmchBean editmchbean = GodmchManageCallService.IniteditmachBean(userId_channl);
			GodmchManageCallService.editmachCall(editmchbean);
		}
		mch_infoWapper mchinfoWapper = new mch_infoWapper();
		HashMap<String, Object> map = new HashMap();
		map.put("mchId", userId_channl);
		mch_info act_info = mchinfoWapper.selectby(map).get(0);

		bean.setMchId(userId_channl);
		bean.setMchShareType(act_info.getMchShareType());// 分享方式1：小程序 2：H5
															// 3：独立小程序 4：独立h5
															// 5：继承版小程序
		bean.setMchStatus(0);
		bean.setRemark("test");

		bean.setPayMode(act_info.getPayMode());//// 支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
		bean.setAliPayMode(act_info.getAliPayMode());// 支付宝支付通道0：不支持支付宝 1：飞界国际
		// 新字段
		bean.setMchSideBuy(1);// 商家端购买1：二维码购买 2：直接购买
		bean.setDualMode(act_info.getDualMode());// 双店模式0：正常模式（默认）1：双店模式
		// 风控字段
		bean.setProductRiskAmount(new BigDecimal(20000));// 商品发布风控金额 0 or null
															// 表示无限制
		bean.setTradeRiskAmount(new BigDecimal(25000));// 交易发布风控金额 0 or null
														// 表示无限制
		mch_configExample example = new mch_configExample();
		example.createCriteria().andMchIdEqualTo(bean.getMchId());
		List<mch_config> mchconfigs = mchconfigWapper.selectByExample(example);
		if (mchconfigs.size() > 0) {
			mch_config mchconfig = mchconfigs.get(0);
			// 新增 20200425 是否支持海外地址
			bean.setOverseasAddressEnabled(mchconfig.getOverseasAddressEnabled());
			// 是否开启图片补白功能
			bean.setProductPicAutoFill(mchconfig.getProductPicAutoFill());
		}

		return bean;
	}

	/**
	 * 商户店铺分享与支付通道合并,此接口给交易张翼使用
	 * 
	 * @param userId_channl
	 * @return
	 * @throws Exception
	 */
	public static setShareTypeBean initsetShareTypeV3(setShareTypeBean bean) throws Exception {
		// 风控字段
		bean.setProductRiskAmount(new BigDecimal(20000));// 商品发布风控金额 0 or null
															// 表示无限制
		bean.setTradeRiskAmount(new BigDecimal(25000));// 交易发布风控金额 0 or null
														// 表示无限制

		return bean;
	}

	public static setShareTypeCall setShareTypeV2Call(setShareTypeBean bean)
			throws ClientProtocolException, IOException {
		setShareTypeCall call = new setShareTypeCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 设置商户支付通道
	 * 
	 * @param mchId   商户
	 * @param payMode 支付通道
	 * @return
	 * @throws Exception
	 */
	public static setShareTypeCall initsetShareTypeV3(Integer mchId, Integer payMode) throws Exception {
		setShareTypeBean bean = new setShareTypeBean();
		setShareTypeCall call = new setShareTypeCall();
		// 获取商户信息
		HashMap<String, Object> map = new HashMap();
		map.put("mchId", mchId);
		mch_info act_info = mchinfoWapper.selectby(map).get(0);
		// 获取商户配置信息
		mch_configExample example = new mch_configExample();
		example.createCriteria().andMchIdEqualTo(bean.getMchId());
		mch_config mchconfig = mchconfigWapper.selectByExample(example).get(0);

		bean.setMchId(mchId);
		bean.setMchShareType(act_info.getMchShareType());// 分享方式1：小程序 2：H5
															// 3：独立小程序 4：独立h5
															// 5：继承版小程序
		bean.setMchStatus(0);
		bean.setRemark(act_info.getRemark());

		bean.setPayMode(payMode);//// 支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
		bean.setAliPayMode(act_info.getAliPayMode());// 支付宝支付通道0：不支持支付宝 1：飞界国际
		// 新字段
		bean.setMchSideBuy(mchconfig.getMchSideBuy());// 商家端购买1：二维码购买 2：直接购买
		bean.setDualMode(act_info.getDualMode());// 双店模式0：正常模式（默认）1：双店模式
		// 风控字段
		bean.setProductRiskAmount(new BigDecimal(20000));// 商品发布风控金额 0 or null
															// 表示无限制
		bean.setTradeRiskAmount(new BigDecimal(25000));// 交易发布风控金额 0 or null
														// 表示无限制
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 根据商户创建代理
	 * 
	 * @param mchId_channl
	 * @return
	 * @throws Exception
	 */
	public static Integer createAgent(Integer mchId_channl) throws Exception {
		UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
		int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
		List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl,
				userId_agent);
		String status = GodmchManageCallService
				.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));
		int redo = 1;
		while (!status.equals("200") && redo < 3) {
			Thread.sleep(3000);
			redo++;
			status = GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));

		}
		return userId_agent;
	}

	/**
	 * * 根据商户创建代理-指定国家
	 * 
	 * @param mchId_channl
	 * @param country      JPN
	 * @return
	 * @throws Exception
	 */
	public static Integer createAgent(Integer mchId_channl, String country) throws Exception {
		UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
		int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
		List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl,
				userId_agent);
		createmchList.get(0).setCountry(country);
		GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));
		return userId_agent;
	}

	/**
	 * 添加服务商
	 * 
	 * @return
	 * @throws Exception
	 */
	public static createmchBean InitAddProvider() throws Exception {

		addProviderBean bean = new addProviderBean();
		addProviderCall call = new addProviderCall();

		UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
		int userId_channl = DGUserCallService.UserCreateCall(usercreateBean);
		// 渠道
		createmchBean createBean = InitcreatemchBeanForChannel(userId_channl);
		createmchCallForChannel(createBean);

		List<String> countryList = new ArrayList<>();
		countryList.add("CAN");
		countryList.add("USA");
		List<Integer> serviceType = new ArrayList<>();
		serviceType.add(1);
		bean.setProviderId(userId_channl);
		bean.setServiceType(serviceType);
		bean.setCountryList(countryList);
		call.setData(bean);
		call.callService();
		return createBean;

	}

	public static addProviderBean InitAddProviderBean() throws Exception {
		addProviderBean bean = new addProviderBean();

		UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
		int userId_channl = DGUserCallService.UserCreateCall(usercreateBean);
		// 渠道
		createmchBean createBean = InitcreatemchBeanForChannel(userId_channl);
		createmchCallForChannel(createBean);

		List<String> countryList = new ArrayList<>();
		countryList.add("CAN");
		countryList.add("USA");
		List<Integer> serviceType = new ArrayList<>();
		serviceType.add(1);
		bean.setProviderId(userId_channl);
		bean.setServiceType(serviceType);
		bean.setCountryList(countryList);
		return bean;
	}

	public static addProviderCall InitAddProviderCall(addProviderBean bean) throws Exception {
		addProviderCall call = new addProviderCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 为渠道商指定服务商
	 * 
	 * @param providerId
	 * @param mchId
	 * @param serviceType
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void InitAddServiceRelation(int providerId, int mchId, int serviceType)
			throws ClientProtocolException, IOException {
		addServiceRelationBean bean = new addServiceRelationBean();
		addServiceRelationCall call = new addServiceRelationCall();

		List<Integer> serviceTypes = new ArrayList<>();
		serviceTypes.add(serviceType);
		bean.setProviderId(providerId);
		bean.setMchId(mchId);
		bean.setServiceType(serviceTypes);
		call.setData(bean);
		call.callService();

	}

	public static void AddAfterService(int parentMchId, int mchId_agent) throws ClientProtocolException, IOException {
		AddAfterServiceInfoBean bean = new AddAfterServiceInfoBean();
		AddAfterServiceInfoCall call = new AddAfterServiceInfoCall();
		bean.setMchId(mchId_agent);
		bean.setParentMchId(parentMchId);
		bean.setRemark("备注_" + TestDataManager.getRandomNum(4));
		bean.setMobile(TestDataManager.getPhoneNum());
		bean.setWeChat("微信号_" + TestDataManager.getRandomNum(4));
		bean.setAddress("地址_" + TestDataManager.getRandomNum(4));
		call.setData(bean);
		call.callService();
	}

	public static setWaterMarkBean SetWaterMark(int mchId) throws ClientProtocolException, IOException {
		setWaterMarkBean bean = new setWaterMarkBean();
		setWaterMarkCall call = new setWaterMarkCall();

		bean.setMchId(mchId);
		bean.setWaterMark(true);
		bean.setAgentWaterMark(true);
		call.setData(bean);
		call.callService();
		return bean;
	}

	/**
	 * 服务商详情（by id）
	 * 
	 * @throws Exception
	 */
	public static getProviderByIdCall getProviderById() throws Exception {
		getProviderByIdBean getbean = new getProviderByIdBean();
		getProviderByIdCall getcall = new getProviderByIdCall();

		List<Integer> serviceType = new ArrayList<>();
		serviceType.add(3);
		addProviderBean bean = InitAddProviderBean();
		bean.setServiceType(serviceType);
		addProviderCall call = InitAddProviderCall(bean);

		getbean.setProviderId(bean.getProviderId());
		getcall.setData(getbean);
		getcall.callService();
		return getcall;
	}

	public static void Demo() throws Exception {

		CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
		String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
		Integer agentid = GodmchManageCallService.CreateSellerMch(code);
		UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
		int csId = DGUserCallService.UserCreateCall(usercreateBean);
		GodmchManageCallService.CreateCSCall(ccbean.getMchId(), csId, 1);
	}

	/**
	 * 创建独立商户bean
	 */
	public static createIndepMchBean InitCreateIndepMchBean() {

		createIndepMchBean bean = new createIndepMchBean();
		bean.setCountry("USA");
		bean.setAreaCode("021");
		bean.setMobile("186" + TestDataManager.getRandomIntNum(8));
		bean.setPassword("111aaa");
		bean.setLogo(
				"http://pc1.img.shop2cn.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
		bean.setTitle("自动化测试创建独立商户_" + TestDataManager.getRandomIntNum(5));
		bean.setHomeBanner(
				"http://pc1.img.shop2cn.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
		bean.setDomain("www.ymatou_" + TestDataManager.getRandomIntNum(10) + ".com");
		bean.setWxAppId("wxAppId_" + TestDataManager.getRandomIntNum(5));
		bean.setWxSecret("wxSecret_" + TestDataManager.getRandomIntNum(5));
		bean.setWxAppIdBuyer("wxAppIdBuyer_" + TestDataManager.getRandomIntNum(5));
		bean.setWxSecretBuyer("wxSecretBuyer_" + TestDataManager.getRandomIntNum(5));
		bean.setWxAppIdPc("wxAppIdPc_" + TestDataManager.getRandomIntNum(5));
		bean.setWxSecretPc("wxSecretPc_" + TestDataManager.getRandomIntNum(5));
		bean.setWxAppIdApp("wxAppIdApp_" + TestDataManager.getRandomIntNum(5));
		bean.setWxSecretApp("wxSecretApp_" + TestDataManager.getRandomIntNum(5));
		bean.setWxAppIdH5("wxAppIdH5_" + TestDataManager.getRandomIntNum(5));
		bean.setWxSecretH5("wxSecretH5_" + TestDataManager.getRandomIntNum(5));
		bean.setHpAccount("hpAccount_" + TestDataManager.getRandomIntNum(5));

		bean.setServicePolicy("www.baidu.com_" + TestDataManager.getRandomIntNum(5));
		bean.setMchShareType(2);// 店铺买家端呈现形式//1：小程序 2：H5 3：独立小程序 4：独立h5 5：继承版小程序
		bean.setAgentPublish(true);
		bean.setAgentInvite(false);
		bean.setAgentInheritShareType(true);
		bean.setAppSource(60);// 代购神器买家端小程序
		bean.setTerminalSource(0);// 其他 default
		// 备案 20200302 此字段是必填项，若不传程序不会出错，程序数据库中做了等于空处理
		bean.setIcpName("自动化自动化测试备案公司名称_" + TestDataManager.getRandomIntNum(5));
		bean.setIcpCode("自动化自动化测试备案号_" + TestDataManager.getRandomIntNum(5));

		return bean;
	}

	/**
	 * 创建独立商户Call
	 * 
	 * @param bean
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static createIndepMchCall CreateIndepMchCall(createIndepMchBean bean)
			throws ClientProtocolException, IOException {

		createIndepMchCall call = new createIndepMchCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 独立商户申请代理并审核通过
	 * 
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static applyAgentCall applyAndapproveAgent(Integer mchId)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {

		// 考虑到需要使用代理，所以返回申请代理call，代理Id：applyCall.getAgentId()
		Thread.sleep(5000);// 休眠目的是为了创建独立商户，把对应的配置 同步到用户那边，然后用户 拿到配置再创建代理
		// 2：申请代理
		applyAgentBean applyBean = GodmchManageCallService.InitApplyAgentBean();
		applyBean.setMchId(mchId);
		applyBean.setAppKey("appsqSeller_" + mchId);
		applyAgentCall applyCall = GodmchManageCallService.ApplyAgentCall(applyBean);
		// 代理类型
		createagentBean agentBean = GodmchManageCallService.InitCreateAgentTypeBean(applyBean.getMchId());
		createagentCall agentCall = GodmchManageCallService.CreateAgentTypeCall(agentBean);
		// 查询代理类型
		Map<String, Object> map = new HashMap();
		map.put("mchId", applyBean.getMchId());
		List<agent_type> list = GodmchManageCallService.agentTypeWapper.selectby(map);
		// 3:审核代理
		approveAgentBean approveAgentBean = new approveAgentBean();
		approveAgentBean.setMchId(applyBean.getMchId());
		approveAgentBean.setAgentId(applyCall.getAgentId());
		approveAgentBean.setAgentType(list.get(0).getAgentType());
		approveAgentBean.setAgentMode(1);

		GodmchManageCallService.ApproveAgentCall(approveAgentBean);

		return applyCall;
	}

	/**
	 * 申请成为代理商bean-未审核
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static applyAgentBean InitApplyAgentBean()
			throws ClientProtocolException, IOException, JSONException, InterruptedException {
		applyAgentBean bean = new applyAgentBean();

		createIndepMchBean createBean = InitCreateIndepMchBean();
		createIndepMchCall createCall = CreateIndepMchCall(createBean);
		Thread.sleep(5000);// 休眠目的是为了创建独立商户，把对应的配置 同步到用户那边，然后用户 拿到配置再创建代理
		bean.setMchId(createCall.getmchId());
		bean.setCountry("USA");
		bean.setMobile("186" + TestDataManager.getRandomIntNum(8));
		bean.setPassword("1111aaaa");
		bean.setAppSource(60);
		bean.setTerminalSource(0);
		bean.setAppKey("appsqSeller_" + createCall.getmchId());
		return bean;
	}

	/**
	 * 申请成为代理商call-未审核
	 * 
	 * @param bean
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static applyAgentCall ApplyAgentCall(applyAgentBean bean) throws ClientProtocolException, IOException {
		applyAgentCall call = new applyAgentCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 独立渠道-申请代理-审核通过bean
	 * 
	 * @return
	 * @throws JSONException
	 * @throws InterruptedException
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static approveAgentBean InitApproveAgentBean()
			throws JSONException, InterruptedException, ClientProtocolException, IOException {
		approveAgentBean bean = new approveAgentBean();

		// 申请代理
		applyAgentBean applyBean = InitApplyAgentBean();
		applyAgentCall applyCall = ApplyAgentCall(applyBean);
		// 代理类型
		createagentBean agentBean = InitCreateAgentTypeBean(applyBean.getMchId());
		createagentCall agentCall = CreateAgentTypeCall(agentBean);
		// 查询代理类型
		Map<String, Object> map = new HashMap();
		map.put("mchId", applyBean.getMchId());
		List<agent_type> list = agentTypeWapper.selectby(map);

		bean.setMchId(applyBean.getMchId());
		bean.setAgentId(applyCall.getAgentId());
		bean.setAgentType(list.get(0).getAgentType());
		bean.setAgentMode(1);
		return bean;
	}

	/**
	 * 独立渠道-申请代理-审核通过call
	 * 
	 * @param bean
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static approveAgentCall ApproveAgentCall(approveAgentBean bean) throws ClientProtocolException, IOException {
		approveAgentCall call = new approveAgentCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	public static approveAgentBean approveAgentBeanV2(Integer mchId, Integer agentId)
			throws JSONException, InterruptedException, ClientProtocolException, IOException {
		approveAgentBean bean = new approveAgentBean();
		// 查询代理类型
		Map<String, Object> map = new HashMap();
		map.put("mchId", mchId);
		List<agent_type> list = agentTypeWapper.selectby(map);

		bean.setMchId(mchId);
		bean.setAgentId(agentId);
		bean.setAgentType(list.get(0).getAgentType());
		bean.setAgentMode(1);
		return bean;
	}

	/**
	 * 神器被拒绝Bean
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static rejectAgentBean initRejectAgentBean()
			throws ClientProtocolException, IOException, JSONException, InterruptedException {

		rejectAgentBean bean = new rejectAgentBean();

		applyAgentBean applyBean = GodmchManageCallService.InitApplyAgentBean();
		applyAgentCall applyCall = GodmchManageCallService.ApplyAgentCall(applyBean);

		bean.setMchId(applyBean.getMchId());
		bean.setAgentId(applyCall.getAgentId());
		bean.setReason("代理审核拒绝_" + TestDataManager.getRandomIntNum(5));
		return bean;
	}

	/**
	 * 神器被拒绝call
	 * 
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static rejectAgentCall rejectAgentCall(rejectAgentBean bean) throws ClientProtocolException, IOException {
		rejectAgentCall call = new rejectAgentCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 重新申请
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static reApplyAgentBean initReApplyAgentBean(Integer mchId, Integer agentId)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {

		reApplyAgentBean bean = new reApplyAgentBean();
		bean.setMchId(mchId);
		bean.setAgentId(agentId);
		return bean;
	}

	/**
	 * 神器被拒绝Bean
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static rejectAgentBean initRejectAgentBeanV2(Integer mchId, Integer agentId)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {

		rejectAgentBean bean = new rejectAgentBean();

		bean.setMchId(mchId);
		bean.setAgentId(agentId);
		bean.setReason("代理审核拒绝_" + TestDataManager.getRandomIntNum(5));
		return bean;
	}

	public static reApplyAgentCall reApplyAgentCall(reApplyAgentBean bean) throws ClientProtocolException, IOException {
		reApplyAgentCall call = new reApplyAgentCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 商户主动创建客服bean
	 * 
	 * @param mchId
	 * @return
	 * @throws Exception
	 */
	public static mchCreateCsBean initMchCreateCsBean(Integer... mchId) throws Exception {
		Integer mchId2 = 0;
		mchCreateCsBean bean = new mchCreateCsBean();
		if (mchId.length == 0) {
			createmchBean createmchBean = GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			mchId2 = createmchBean.getMchId();
		} else
			mchId2 = mchId[0];
		bean.setMchId(mchId2);
		bean.setTitle("商户主动创建客服title_" + TestDataManager.getRandomIntNum(5));
		bean.setLoginId("商户主动创建客服_" + TestDataManager.getRandomIntNum(5));
		bean.setPassword("111");
		bean.setTemplateId(1);
		bean.setChannelSource(1);
		bean.setTerminalSource(0);
		bean.setAppSource(60);
		bean.setAppKey("pcsqseller_" + mchId2);
		return bean;
	}

	/**
	 * 商户主动创建客服call
	 * 
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static mchCreateCsCall mchCreateCsCall(mchCreateCsBean bean) throws ClientProtocolException, IOException {
		mchCreateCsCall call = new mchCreateCsCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 设置商户支付通道
	 * 
	 * @param mchId 只能是渠道上才可以切换盛付通
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static SetPayModeCall SetPayMode(Integer mchId) throws ClientProtocolException, IOException {
		SetPayModeBean setpaymodeBean = new SetPayModeBean();
		SetPayModeCall setpaymodeCall = new SetPayModeCall();
		setpaymodeBean.setMchId(mchId);
		setpaymodeBean.setPayMode(3);
		setpaymodeBean.setAliPayMode(0);
		setpaymodeCall.setData(setpaymodeBean);
		setpaymodeCall.callService();
		return setpaymodeCall;
	}

	/**
	 * 设置商户支付通道
	 * 
	 * @param mchId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static SetPayModeBean initSetPayModeBean(Integer mchId) throws ClientProtocolException, IOException {
		SetPayModeBean setpaymodeBean = new SetPayModeBean();
		setpaymodeBean.setMchId(mchId);
		setpaymodeBean.setPayMode(3);
		setpaymodeBean.setAliPayMode(0);
		return setpaymodeBean;
	}

	public static SetPayModeCall SetPayModeCall(SetPayModeBean setpaymodeBean)
			throws ClientProtocolException, IOException {
		SetPayModeCall setpaymodeCall = new SetPayModeCall();
		setpaymodeCall.setData(setpaymodeBean);
		setpaymodeCall.callService();
		return setpaymodeCall;
	}

	public static JsonObject GetMchInfoById(int mchId) throws ClientProtocolException, IOException {
		getMchListByIdListBean bean = new getMchListByIdListBean();
		getMchListByIdListCall call = new getMchListByIdListCall();
		bean.setMchIdList(Arrays.asList(mchId));
		call.setData(bean);
		call.callService();
		return call.getJsonObject().getAsJsonObject("result").getAsJsonArray("mchInfoList").get(0).getAsJsonObject();
	}

	public static JsonObject GetMchAppByMchId(int mchId) throws ClientProtocolException, IOException {

		GetMchAppListBean getmchapplistBean = new GetMchAppListBean();
		GetMchAppListCall getmchapplistCall = new GetMchAppListCall();

		getmchapplistBean.setMchId(mchId);
		getmchapplistCall.setData(getmchapplistBean);
		getmchapplistCall.callService();

		return getmchapplistCall.getJsonObject().getAsJsonObject("data").getAsJsonArray("mchAppListVos").get(0)
				.getAsJsonObject();
	}

	public static JsonObject GetMchAppAllStatus(int mchId) {

		GetMchAppAllStatusBean getmchappallstatusBean = new GetMchAppAllStatusBean();
		GetMchAppAllStatusCall getmchappallstatusCall = new GetMchAppAllStatusCall();

		getmchappallstatusBean.setMchId(mchId);
		getmchappallstatusCall.setData(getmchappallstatusBean);
		try {
			getmchappallstatusCall.callService();
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		Logger.verifyEquals("200", getmchappallstatusCall.getString("code"), "验证返回code");
		return getmchappallstatusCall.getJsonObject().getAsJsonObject("data");
	}

	/**
	 * 商户信息 根据商户获取商户信息
	 * 
	 * @param mchId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static MchInfoVo detailmch(int mchId) throws ClientProtocolException, IOException {

		detailmchBean detailmchbean = new detailmchBean();
		detailmchCall detailmchCall = new detailmchCall();

		detailmchbean.setMchId(mchId);
		detailmchCall.setData(detailmchbean);
		detailmchCall.callService();

		return detailmchCall.getResult();
	}

	public static setChargeConfigBean initSetChargeConfigBean(Integer mchId)
			throws ClientProtocolException, IOException {
		setChargeConfigBean bean = new setChargeConfigBean();
		bean.setMchId(mchId);
		bean.setFreeMiniApp(true);
		bean.setFreeLive(true);
		return bean;
	}

	public static setChargeConfigCall setChargeConfigCall(setChargeConfigBean bean)
			throws ClientProtocolException, IOException {
		setChargeConfigCall call = new setChargeConfigCall();
		call.setData(bean);
		call.callService();

		return call;
	}

	/**
	 * 申请供货商
	 * 
	 * @param mchId
	 * @return
	 * @throws InterruptedException
	 */
	public static applySupplierBean initApplySupplier(Integer mchId) throws InterruptedException {
		Thread.sleep(5000);// 休眠目的是为了创建独立商户，把对应的配置 同步到用户那边，然后用户 拿到配置再创建供货商
		applySupplierBean bean = new applySupplierBean();
		bean.setMchId(mchId);
		bean.setCountry("USA");
		bean.setMobile(TestDataManager.getPhoneNum());
		bean.setPassword(TestDataManager.randomStr(8));
		// bean.setAppSource(TestDataManager.getRandomIntNum(6));
		// bean.setAppSource(60);
		// bean.setTerminalSource(TestDataManager.getRandomIntNum(6));
		// bean.setAppKey("godmch.iapi.ymatou.com");

		bean.setAppKey("appsqSeller_" + mchId);
		bean.setAppSource(60);
		bean.setTerminalSource(0);

		return bean;
	}

	public static applySupplierCall applySupplierCall(applySupplierBean bean)
			throws ClientProtocolException, IOException {
		applySupplierCall call = new applySupplierCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 申请供货商审核通过
	 * 
	 * @param mchId
	 * @param supplierId
	 * @return
	 * @throws JSONException
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws InterruptedException
	 */
	public static approveSupplierCall approveSupplier(Integer mchId, Integer supplierId)
			throws JSONException, ClientProtocolException, IOException, InterruptedException {
		approveSupplierBean bean = new approveSupplierBean();
		approveSupplierCall call = new approveSupplierCall();
		bean.setMchId(mchId);
		bean.setSupplierId(supplierId);
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 申请供货商审核拒绝
	 * 
	 * @param mchId
	 * @param supplierId
	 * @return
	 */
	public static rejectSupplierCall rejectSupplier(Integer mchId, Integer supplierId)
			throws JSONException, ClientProtocolException, IOException, InterruptedException {
		rejectSupplierBean bean = new rejectSupplierBean();
		rejectSupplierCall call = new rejectSupplierCall();
		bean.setMchId(mchId);
		bean.setSupplierId(supplierId);
		bean.setReason("自动化自动化测试审核拒绝" + TestDataManager.getRandomIntNum(5));
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 删除供货商
	 * 
	 * @param mchId
	 * @param supplierId
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static deleteSupplierCall deleteSupplier(Integer mchId, Integer supplierId)
			throws ClientProtocolException, IOException {
		deleteSupplierBean bean = new deleteSupplierBean();
		deleteSupplierCall call = new deleteSupplierCall();

		bean.setMchId(mchId);
		bean.setSupplierId(supplierId);
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 重新申请代理商
	 * 
	 * @param mchId
	 * @param supplierId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static reApplySupplierCall ReApplySupplier(Integer mchId, Integer supplierId)
			throws ClientProtocolException, IOException {
		reApplySupplierBean bean = new reApplySupplierBean();
		reApplySupplierCall call = new reApplySupplierCall();
		bean.setMchId(mchId);
		bean.setSupplierId(supplierId);
		call.setData(bean);
		call.callService();
		return call;
	}

	public static editSupplierBean editSupplier(Integer mchId, Integer supplierId)
			throws ClientProtocolException, IOException {
		editSupplierBean bean = new editSupplierBean();
		editSupplierCall call = new editSupplierCall();
		bean.setMchId(mchId);
		bean.setSupplierId(supplierId);
		bean.setDepot("自动化自动化测试仓库名称_" + TestDataManager.getRandomIntNum(5));
		bean.setRemark("自动化自动化测试编辑供货商备注_" + TestDataManager.getRandomIntNum(5));
		call.setData(bean);
		call.callService();
		return bean;
	}

	/**
	 * 设置前端交互状态
	 * 
	 * @param mchId 商户id
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static setInteractionStateBean SetInteractionState(Integer mchId)
			throws ClientProtocolException, IOException {
		setInteractionStateBean bean = new setInteractionStateBean();
		setInteractionStateCall call = new setInteractionStateCall();
		bean.setMchId(mchId);
		bean.setBizKey("自动化自动化测试bizKey_" + TestDataManager.getRandomIntNum(5));
		bean.setBizValue("自动化自动化测试BizValue_" + TestDataManager.getRandomIntNum(5));
		call.setData(bean);
		call.callService();
		return bean;
	}

	public static setMarketPriceConfigBean initSetMarketPriceBean(Integer... mchId) throws Exception {
		setMarketPriceConfigBean bean = new setMarketPriceConfigBean();
		Integer id = 0;
		if (mchId.length == 0) {
			id = GodmchManageCallService.CreateSellerMch();
		} else {
			id = mchId[0];
		}
		bean.setMchId(id);
		bean.setMarketPriceEnabled(true);
		bean.setMarketPriceTitle("自动化测试市场价标题_" + TestDataManager.getRandomIntNum(5));

		return bean;
	}

	public static setMarketPriceConfigCall setMarketPriceCall(setMarketPriceConfigBean bean)
			throws ClientProtocolException, IOException {
		setMarketPriceConfigCall call = new setMarketPriceConfigCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 初始化自动加价配置
	 * 
	 * @param agentUserId
	 * @param rootUserId
	 * @return
	 * @throws Exception
	 */
	public static SetMarkupConfigBean initSetMarketupBean(Integer agentUserId, List<Integer> rootUserIds)
			throws Exception {
		SetMarkupConfigBean setmarkupconfigBean = new SetMarkupConfigBean();
		setmarkupconfigBean.setAgentId(agentUserId);
		setmarkupconfigBean.setSupplierId(rootUserIds);
		setmarkupconfigBean.setMarkupType(1);
		setmarkupconfigBean.setPercentage(new BigDecimal(33.0));
		setmarkupconfigBean.setDecimalType(1);
		setmarkupconfigBean.setOnSaleType(1);
		setmarkupconfigBean.setRefreshProduct(true);
		return setmarkupconfigBean;
	}

	/**
	 * 新增自动加价配置
	 * 
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static SetMarkupConfigCall SetMarketupBeanCall(SetMarkupConfigBean bean)
			throws ClientProtocolException, IOException {
		SetMarkupConfigCall call = new SetMarkupConfigCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 查询自动加价配置
	 * 
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static GetMarkupConfigCall GetMarketupConfig(int agentUserId, List<Integer> rootUserIds) throws Exception {
		GetMarkupConfigBean getmarkupconfigBean = new GetMarkupConfigBean();
		GetMarkupConfigCall getmarkupconfigCall = new GetMarkupConfigCall();
		getmarkupconfigBean.setAgentId(agentUserId);
		getmarkupconfigBean.setSupplierIdList(rootUserIds);
		getmarkupconfigCall.setData(getmarkupconfigBean);
		getmarkupconfigCall.callService();
		return getmarkupconfigCall;
	}

	/**
	 * 删除自动加价配置
	 * 
	 * @param agentUserId
	 * @param rootUserId
	 * @return
	 * @throws Exception
	 */
	public static DeleteMarkupConfigCall DeleteMarketupConfig(int agentUserId, int rootUserId) throws Exception {
		DeleteMarkupConfigBean deletemarkupconfigBean = new DeleteMarkupConfigBean();
		DeleteMarkupConfigCall deletemarkupconfigCall = new DeleteMarkupConfigCall();
		deletemarkupconfigBean.setAgentId(agentUserId);
		deletemarkupconfigBean.setSupplierId(rootUserId);
		deletemarkupconfigCall.setData(deletemarkupconfigBean);
		deletemarkupconfigCall.callService();
		return deletemarkupconfigCall;
	}

	public static setBuyerCsBean setBuyerCs(Integer mchId) throws ClientProtocolException, IOException {
		setBuyerCsBean bean = new setBuyerCsBean();
		setBuyerCsCall call = new setBuyerCsCall();
		bean.setMchId(mchId);
		bean.setEnabled(true);
		bean.setWechat("test_" + TestDataManager.getRandomIntNum(5));
		call.setData(bean);
		call.callService();
		return bean;
	}

	/**
	 * 创建国内渠道
	 * 
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	public static createmchBean channl_CHN(Integer... channl) throws Exception {
		createmchBean bean = new createmchBean();
		createmchCall call = new createmchCall();
		// 国内渠道
		UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
		int userId = 0;
		if (channl.length > 0)
			userId = channl[0];
		else
			userId = DGUserCallService.UserCreateCall(usercreateBean);

		bean.setMchId(userId);
		bean.setCountry("CHN");
		bean.setNickName("商户昵称_" + TestDataManager.getPhoneNum());
		bean.setCode("GNQDS1");

		call.setData(bean);
		call.callService();
		return bean;
	}

	/**
	 * 设置自动加价规则 若AgentId=null && supplierIds=null 自动创建代理和供货商
	 * 
	 * @param AgentId        代理
	 * @param supplierIds供货商
	 * @return
	 * @throws Exception
	 */

	public static SetMarkupConfigBean initSetMarkupConfigV2(Integer agentId, List<Integer> supplierIds)
			throws Exception {
		if (supplierIds == null && (agentId == null || agentId == 0)) {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(mchId_channl);
			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));

			agentId = createmchList.get(0).getMchId();
			supplierIds = new ArrayList();
			supplierIds.add(mchId_channl);
		}
		SetMarkupConfigBean bean = new SetMarkupConfigBean();
		bean.setAgentId(agentId);
		bean.setSupplierId(supplierIds);
		bean.setMarkupType(1);// 加价类型1按比例加价2建议零售价3不加价
		bean.setOnSaleType(1);// 上架类型1自动添加到我的店2手动上架到我的店
		bean.setPercentage(new BigDecimal(10));// 自动加价百分比,无小数
		bean.setDecimalType(1);// 加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
		return bean;
	}

	/**
	 * 初始化按条件设置自动加价
	 * 
	 * @param agentId    代理id
	 * @param supplierId 供货商id
	 * @param addbean    创建的商品
	 * @param percentage 自动加价百分比
	 * @return
	 * @throws Exception
	 */
	public static setConditionMarkupConfigBean initSetConditionMarkupConfig(Integer agentId, Integer supplierId,Integer percentage,
			AddAgentProductBean addbean) throws Exception {
		setConditionMarkupConfigBean setConditionMarkupConfigBean = new setConditionMarkupConfigBean();
		setConditionMarkupConfigBean.setAgentId(agentId);
		setConditionMarkupConfigBean.setSupplierId(supplierId);
		setConditionMarkupConfigBean.setMarkupType(1);// 加价类型1按比例加价2建议零售价3不加价
		setConditionMarkupConfigBean.setOnSaleType(1);// 上架类型1自动添加到我的店2手动上架到我的店
		setConditionMarkupConfigBean.setPercentage(new BigDecimal(percentage));// 自动加价百分比,无小数
		setConditionMarkupConfigBean.setDecimalType(1);// 加价后小数点类型1,精确到个位数2,保留小数点后1位3,保留小数点后2,位4精确到十位数
		if (addbean != null) {
			// 设置品牌
			setConditionMarkupConfigBean.setBrandList(Arrays.asList(addbean.getBrandId()));
			// 设置仓库
			if (addbean.getDepotId() != null) {
				setConditionMarkupConfigBean.setDepotList(Arrays.asList(addbean.getDepotId()));
			}
			//设置类目-默认
			setConditionMarkupConfigBean.setCategoryList(Arrays.asList(1001));
		}
		return setConditionMarkupConfigBean;
	}
	/**
	 * 按条件设置自动加价
	 * @param setConditionMarkupConfigBean
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void SetConditionMarkupConfigCall(setConditionMarkupConfigBean setConditionMarkupConfigBean) throws ClientProtocolException, IOException {
		setConditionMarkupConfigCall setConditionMarkupConfigCall=new setConditionMarkupConfigCall();
		setConditionMarkupConfigCall.setData(setConditionMarkupConfigBean);
		setConditionMarkupConfigCall.callService();
	}
	/**
	 * 初始化按条件设置自动加价
	 * @param agentId    代理id
	 * @param supplierId 供货商id
	 * @param percentage 自动加价百分比
	 * @param addbean    创建的商品
	 * @param Weight 要设置哪一级默认权重
	 * @throws Exception
	 */
	public static setConditionMarkupConfigBean initDefSetConditionMarkupConfig(Integer agentId, Integer supplierId,Integer percentage,
			AddAgentProductBean addbean,int Weight) throws Exception {
		setConditionMarkupConfigBean setbean =new setConditionMarkupConfigBean();
		setbean=initSetConditionMarkupConfig(agentId, supplierId, percentage, addbean);
		Logger.comment("按照权重创建权重为"+Weight);
		switch (Weight) {
		case 1:
			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
			setbean.setCategoryList(Arrays.asList(1001));
			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 2:
			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
			setbean.setCategoryList(Arrays.asList(1001));
//			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 3:
			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
//			setbean.setCategoryList(Arrays.asList(1001));
			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 4:
//			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
			setbean.setCategoryList(Arrays.asList(1001));
			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 5:
			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
//			setbean.setCategoryList(Arrays.asList(1001));
//			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 6:
//			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
			setbean.setCategoryList(Arrays.asList(1001));
//			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		case 7:
//			setbean.setBrandList(Arrays.asList(addbean.getBrandId()));
//			setbean.setCategoryList(Arrays.asList(1001));
			setbean.setDepotList(Arrays.asList(addbean.getDepotId()));
			break;
		default:
			break;
		}
		return setbean;
	}
	public static adminBindAgentBean initAdminBindAgent(Integer mchId, Integer agentId) {
		adminBindAgentBean bean = new adminBindAgentBean();
		bean.setMchId(mchId);
		bean.setAgentId(agentId);
		bean.setMobile(TestDataManager.getPhoneNum());
		bean.setWechat("微信号_" + TestDataManager.getRandomNum(5));
		bean.setRemark("备注_" + TestDataManager.getRandomNum(5));
		return bean;
	}

	public static adminBindAgentCall AdminBindAgent(adminBindAgentBean bean)
			throws ClientProtocolException, IOException {
		adminBindAgentCall call = new adminBindAgentCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	public static createDepotBean createDepot(Integer mchId) throws ClientProtocolException, IOException {
		createDepotBean bean = new createDepotBean();
		createDepotCall call = new createDepotCall();

		bean.setMchId(mchId);
		bean.setDepotTitle(mchId+"_" + TestDataManager.getRandomIntNum(5));
		bean.setRemark("新增仓库信息_" + TestDataManager.getRandomIntNum(5));
		bean.setBuyerTitle("买家端显示名称_" + TestDataManager.getRandomNum(5));
		bean.setPicUrl("http://www.baidu.com_" + TestDataManager.getRandomNum(5) + ".jpg");
		call.setData(bean);
		call.callService();
		return bean;
	}

	public static List<mch_depot_info> SelectDepotByMchId(Integer mchId) throws InterruptedException {
		mch_depot_infoWapper depotWapper = new mch_depot_infoWapper();
		mch_depot_infoExample example = new mch_depot_infoExample();
		example.createCriteria().andMchIdEqualTo(mchId);
		List<mch_depot_info> lst = depotWapper.selectByExample(example);
		return lst;
	}

	public static List<mch_depot_info> SelectDepotByMchIdAndSuccess(Integer mchId) throws InterruptedException {
		mch_depot_infoWapper depotWapper = new mch_depot_infoWapper();
		mch_depot_infoExample example = new mch_depot_infoExample();
		example.createCriteria().andMchIdEqualTo(mchId).andDepotStatusEqualTo(0);
		List<mch_depot_info> lst = depotWapper.selectByExample(example);
		return lst;
	}

	public static List<mch_depot_info> SelectDepotByDepotTitle(String depotTitle) throws InterruptedException {
		mch_depot_infoWapper depotWapper = new mch_depot_infoWapper();
		mch_depot_infoExample example = new mch_depot_infoExample();
		example.createCriteria().andDepotTitleEqualTo(depotTitle);
		List<mch_depot_info> lst = depotWapper.selectByExample(example);
		return lst;
	}

	public static createSupplierCodeCall createSupplierCode(Integer mchId) throws ClientProtocolException, IOException {
		createSupplierCodeBean createSupplierCodeBean = new createSupplierCodeBean();
		createSupplierCodeCall createSupplierCodeCall = new createSupplierCodeCall();
		createSupplierCodeBean.setMchId(mchId);
		createSupplierCodeCall.setData(createSupplierCodeBean);
		createSupplierCodeCall.callService();
		return createSupplierCodeCall;
	}

	/**
	 * 独立云邀请码注册
	 * 
	 * @param mchId 独立商户
	 * @param code  供货商邀请码或者代理邀请码
	 * @return
	 * @throws InterruptedException
	 */
	public static registerByCodeBean initRegisterByCode(Integer mchId, String code) throws InterruptedException {
		registerByCodeBean bean = new registerByCodeBean();
		registerByCodeCall call = new registerByCodeCall();

		Thread.sleep(5000);
		bean.setMchId(mchId);
		bean.setCountry("USA");
		bean.setMobile(TestDataManager.getPhoneNum());
		bean.setPassword("testanc" + TestDataManager.getRandomNum(2));
		bean.setAppSource(60);// 代购神器买家端小程序
		bean.setTerminalSource(0);// 其他 default
		bean.setAppKey("appsqSeller_" + mchId);
		bean.setInviteCode(code);
		return bean;
	}

	public static registerByCodeCall registerByCodeCall(registerByCodeBean bean)
			throws ClientProtocolException, IOException {
		registerByCodeCall call = new registerByCodeCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	public static getInviteDistributorPicBean initGetInviteDistributorPicBean(Integer... distributorId)
			throws Exception {
		getInviteDistributorPicBean bean = new getInviteDistributorPicBean();
		if (distributorId.length == 0) {
			int userId = GodmchManageCallService.CreateSellerMch();
			editmchBean editmchBean = GodmchManageCallService.IniteditmachBean(userId);
			GodmchManageCallService.editmachCall(editmchBean);
			bean.setDistributorId(userId);
		} else {
//			createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(distributorId[0]);
//			GodmchManageCallService.createmchCallForChannel(createmchbean2);
//			editmchBean editmchBean=GodmchManageCallService.IniteditmachBean(distributorId[0]);
//			GodmchManageCallService.editmachCall(editmchBean);
			bean.setDistributorId(distributorId[0]);
		}
		return bean;
	}

	public static getInviteDistributorPicCall getInviteDistributorPicBeanCall(getInviteDistributorPicBean bean)
			throws ClientProtocolException, IOException {
		getInviteDistributorPicCall call = new getInviteDistributorPicCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	public static void setMchAllConfig(Integer mchId, Map<String, Object> map)
			throws ClientProtocolException, IOException {
		setMchAllConfigBean bean = new setMchAllConfigBean();
		setMchAllConfigCall call = new setMchAllConfigCall();
		bean.setMchId(mchId);
		bean.setconfigMap(map);
		call.setData(bean);
		call.callService();
	}

	/**
	 * 创建分销员 registerByCodeCall RegMchId对象返回分享员Id
	 * 
	 * @throws Exception
	 */
	public static void createDistributor() throws Exception {
		createIndepMchBean createIndepMchBean = GodmchManageCallService.InitCreateIndepMchBean();
		createIndepMchCall createIndepMchCall = GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
		Integer mchId = createIndepMchCall.getmchId();
		Logger.comment("###########独立商户：" + mchId);

		Logger.comment("###########独立商户审核：");
		SqDistributorService.createAutoAuditDistributor((long) mchId);

		// 独立商户邀请分享图
		getInviteDistributorPicBean getInviteDistributorPicBean = GodmchManageCallService
				.initGetInviteDistributorPicBean(mchId);
		getInviteDistributorPicCall getInviteDistributorPicCall = GodmchManageCallService
				.getInviteDistributorPicBeanCall(getInviteDistributorPicBean);
		Logger.comment("###########独立商户图片：");

		registerByCodeBean registerByCodeBean = GodmchManageCallService.initRegisterByCode(mchId,
				getInviteDistributorPicCall.getResult().get("inviteCode").getAsString());
		registerByCodeCall registerByCodeCall = GodmchManageCallService.registerByCodeCall(registerByCodeBean);

	}

	private static applyAgentCall applyAgent(CreateCodeBean createCodeBean, int mchId)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {
		CreateCodeCall createCodeCall = GodmchManageCallService.createCodeCall(createCodeBean);
		applyAgentBean applyAgentBean = new applyAgentBean();
		applyAgentCall applyAgentCall = new applyAgentCall();
		Thread.sleep(5000);// 休眠目的是为了创建独立商户，把对应的配置 同步到用户那边，然后用户 拿到配置再创建代理
		applyAgentBean.setMchId(mchId);
		applyAgentBean.setCountry("CHN");
		applyAgentBean.setMobile("186" + TestDataManager.getRandomIntNum(8));
		applyAgentBean.setPassword("111aaaa");
		applyAgentBean.setAppKey("appsqSeller_" + mchId);
		applyAgentBean.setAppSource(60);
		applyAgentBean.setTerminalSource(3);
		applyAgentBean.setInviteCode(createCodeCall.getCode());
		applyAgentCall.setData(applyAgentBean);
		applyAgentCall.callService();
		return applyAgentCall;
	}

	private static applyAgentCall applyAgent(CreateCodeBean createCodeBean, int mchId, int AgentId)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {
		CreateCodeCall createCodeCall = GodmchManageCallService.createCodeCall(createCodeBean);
		applyAgentBean applyAgentBean = new applyAgentBean();
		applyAgentCall applyAgentCall = new applyAgentCall();
		Thread.sleep(5000);// 休眠目的是为了创建独立商户，把对应的配置 同步到用户那边，然后用户 拿到配置再创建代理
		applyAgentBean.setMchId(AgentId);
		applyAgentBean.setCountry("CHN");
		applyAgentBean.setMobile("186" + TestDataManager.getRandomIntNum(8));
		applyAgentBean.setPassword("111aaaa");
		applyAgentBean.setAppKey("appsqSeller_" + mchId);
		applyAgentBean.setAppSource(60);
		applyAgentBean.setTerminalSource(3);
		applyAgentBean.setInviteCode(createCodeCall.getCode());
		applyAgentCall.setData(applyAgentBean);
		applyAgentCall.callService();
		return applyAgentCall;
	}

	/**
	 * 直接创建一个独立商户
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 */
	public static Integer CreateGodMch() throws ClientProtocolException, IOException, JSONException {
		return CreateGodMch(true, true);
	}

	/**
	 * 直接创建一个独立商户
	 * 
	 * @param AgentPublish 代理商能否发布商品
	 * @param tAgentInvite 代理商能否邀请代理
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 */
	public static Integer CreateGodMch(Boolean AgentPublish, Boolean tAgentInvite)
			throws ClientProtocolException, IOException, JSONException {
		createIndepMchBean createBean = GodmchManageCallService.InitCreateIndepMchBean();
		createBean.setAgentPublish(AgentPublish);
		createBean.setAgentInvite(tAgentInvite);
		createIndepMchCall createCall = GodmchManageCallService.CreateIndepMchCall(createBean);
		return createCall.getmchId();
	}

	/**
	 * 根据独立商户创建一个分销小店
	 * 
	 * @param MchId
	 */
	public static Integer CreateStores(int MchId, int RebateRate)
			throws ClientProtocolException, IOException, InterruptedException, JSONException {
		// 邀请码
		CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(MchId, true);
		// 创建代理类型
		createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(MchId);
		createagentBean.setAgentMode(2);//
		createagentBean.setRebateRate(new BigDecimal(RebateRate));
		createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
		// 查询类型
		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", MchId);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		createCodeBean.setRoleType(agenttypeList.get(agenttypeList.size() - 1).getAgentType());
		// 申请独立商户
		applyAgentCall applyAgentCall = GodmchManageCallService.applyAgent(createCodeBean, MchId);
		return applyAgentCall.getAgentId();

	}

	/**
	 * 根据代理创建一个分销小店
	 * 
	 * @param MchId
	 */
	public static Integer CreateStoresByAgent(int mchId, int AgentId, int RebateRate)
			throws ClientProtocolException, IOException, InterruptedException, JSONException {
		// 邀请码
		CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(AgentId, true);
		// 创建代理类型
		createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(AgentId);
		createagentBean.setAgentMode(2);//
		createagentBean.setRebateRate(new BigDecimal(RebateRate));
		createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
		// 查询类型
		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", AgentId);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		createCodeBean.setRoleType(agenttypeList.get(agenttypeList.size() - 1).getAgentType());
		// 申请独立商户
		applyAgentCall applyAgentCall = GodmchManageCallService.applyAgent(createCodeBean, mchId, AgentId);
		return applyAgentCall.getAgentId();
	}

	/**
	 * 根据独立商户的代理创建一个代理
	 * 
	 * @param MchId
	 */
	public static Integer CreateAgent(int Agent, int MchId)
			throws ClientProtocolException, IOException, InterruptedException, JSONException {
		// 邀请码
		CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(Agent, true);
		// 创建代理类型
		createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(Agent);
		createagentBean.setAgentMode(1);//
		createagentBean.setRebateRate(new BigDecimal(0));
		createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
		// 查询类型
		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", Agent);

		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		createCodeBean.setRoleType(agenttypeList.get(agenttypeList.size() - 1).getAgentType());
		// 申请独立商户
		applyAgentCall applyAgentCall = GodmchManageCallService.applyAgent(createCodeBean, MchId, Agent);

		return applyAgentCall.getAgentId();

	}

	/**
	 * 根据独立商户创建一个代理
	 * 
	 * @param MchId
	 */
	public static Integer CreateAgent(int MchId)
			throws ClientProtocolException, IOException, InterruptedException, JSONException {
		// 邀请码
		CreateCodeBean createCodeBean = GodmchManageCallService.InitcreateCodeBeanForAgent(MchId, true);
		// 创建代理类型
		createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(MchId);
		createagentBean.setAgentMode(1);//
		createagentBean.setRebateRate(new BigDecimal(0));
		createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
		// 查询类型
		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", MchId);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		createCodeBean.setRoleType(agenttypeList.get(agenttypeList.size() - 1).getAgentType());
		// 申请独立商户
		applyAgentCall applyAgentCall = GodmchManageCallService.applyAgent(createCodeBean, MchId);
		return applyAgentCall.getAgentId();

	}

	/**
	 * 获取一个mchid的代理类型
	 * 
	 * @param mchId     可从CreateGodMch创建
	 * @param agentmode 代理模式 1 - 自主选货（分销代理）2 - 自动继承（分销小店）
	 * @return
	 * @throws InterruptedException
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static Integer getAgentType(Integer mchId, Integer agentmode)
			throws InterruptedException, ClientProtocolException, IOException {
		agent_typeWapper agentTypewapper = new agent_typeWapper();
		Map<String, Object> map = new HashMap();
		map.put("mchId", mchId);
		List<agent_type> agenttypeList = agentTypewapper.selectby(map);
		agent_type agent = agenttypeList.stream().filter(x -> x.getAgentMode().equals(agentmode)).findFirst()
				.orElse(null);
		if (agent != null) {
			return agent.getAgentType();
		} else {
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			/** 代理模式 1 - 自主选货（分销代理）2 - 自动继承（分销小店） */
			createagentBean.setAgentMode(agentmode);
			createagentCall createagentcall = CreateAgentTypeCall(createagentBean);
			agenttypeList = agentTypewapper.selectby(map);
			agent = agenttypeList.stream().filter(x -> x.getAgentMode().equals(agentmode)).findFirst().orElse(null);
			return agent.getAgentType();
		}

	}

	/**
	 * 创建一个代理商户
	 * 
	 * @param mchId     主商户
	 * @param agenttype 代理type 从getAgentType获取
	 * @return mchId_Agent 代理商户id
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	public static Integer getAgentMchId(Integer mchId, Integer agenttype)
			throws ClientProtocolException, IOException, JSONException, InterruptedException {
		editmchBean editmchBean = GodmchManageCallService.IniteditmachBean(mchId);
		GodmchManageCallService.editmachCall(editmchBean);
		CreateCodeBean bean = new CreateCodeBean();
		bean.setMchId(mchId);
		bean.setCodeRole(1);
		bean.setRoleType(agenttype);// 代理类型(如：北京代理，上海代理)
		bean.setIsPermanently(true);
		CreateCodeCall call = new CreateCodeCall();
		call.setData(false, bean);
		call.callService();
		if (!call.getSuccess()) {
			Thread.sleep(3000);
			call.callService();
		}
		String code = call.getCode();
		registerByCodeBean regbean = GodmchManageCallService.initRegisterByCode(mchId, code);
		Integer mchId_Agent = GodmchManageCallService.registerByCodeCall(regbean).getRegMchId();
		return mchId_Agent;
	}
	
	/**
	 * 设置自动加价bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 */
	public static setConditionMarkupConfigBean initSetConditionMarkupConfig(Integer agentId,Integer supplierId)
	{
		setConditionMarkupConfigBean bean=new setConditionMarkupConfigBean();
		bean.setAgentId(agentId);
		bean.setSupplierId(supplierId);
		bean.setOnSaleType(1);
	    bean.setMarkupType(1);
	    bean.setPercentage(new BigDecimal(1));
	    bean.setDecimalType(1);
	    //品牌
	    bean.setBrandList(Lists.newArrayList(Integer.parseInt(TestDataManager.getRandomNum(5))));
	    return bean;
	}
	/**
	 * 设置自动加价Call
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static setConditionMarkupConfigCall setConditionMarkupConfigCall(setConditionMarkupConfigBean bean) throws ClientProtocolException, IOException
	{
		setConditionMarkupConfigCall call=new setConditionMarkupConfigCall();
		call.setData(bean);
		call.callService();
		return call;
	}

	/**
	 * 设置自动加价bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 */
	public static updateConditionMarkupConfigBean initUpdateConditionMarkupConfig(Integer agentId,Integer supplierId,Integer markupId,setConditionMarkupConfigBean setBean)
	{
		updateConditionMarkupConfigBean bean=new updateConditionMarkupConfigBean();
		bean.setAgentId(agentId);
		bean.setSupplierId(supplierId);
		bean.setMarkupId(markupId);
	    
	    bean.setPercentage(new BigDecimal(1));
	    bean.setDecimalType(1);
	    bean.setBrandList(setBean.getBrandList());
	    bean.setCategoryList(setBean.getCategoryList());
	    bean.setDepotList(setBean.getDepotList());
	    bean.setMarkupType(setBean.getMarkupType());
	    bean.setPercentage(setBean.getPercentage());
	    bean.setDecimalType(setBean.getDecimalType());
	    bean.setOnSaleType(setBean.getOnSaleType());
	    bean.setRefreshProduct(setBean.getRefreshProduct());
	    return bean;
	}
	
	
	
	//创建代理
	public static Integer createAgent() throws Exception
	{
		//代理
		CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
		String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
		Integer agentId = GodmchManageCallService.CreateSellerMch(code);
		GodmchManageCallService.editMchInfo(ccbean.getMchId(),"title1", DGUserCallService.DefImg2,"wc2");
		return agentId;
	}
	public static applySupplierCall createApplySupplier() throws ClientProtocolException, IOException, JSONException, InterruptedException
	{
		//供货商
		createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
        createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
        applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
        applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
		GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(),applySupplierCall.getSupplierId());
		return applySupplierCall;
	}
	
	/**
	 * 设置优先条件
	 * @return
	 * @throws Exception
	 */
	public static setConditionLevelBean initSetConditionLevelBean() throws Exception
	{
		setConditionLevelBean bean=new setConditionLevelBean();
		 Integer agentId=createAgent();
         Integer supplierId=createApplySupplier().getSupplierId();
		//新增
         setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(agentId,supplierId);
         setConditionMarkupConfigCall(setBean);
         
         bean.setAgentId(agentId);
         bean.setSupplierId(supplierId); 
	    List<condition> lst=new ArrayList<condition>();
	    condition con=new condition();
	    con.setConditionType(5);
	    con.setConditionLevel(8);
	    lst.add(con);
   		bean.setList(lst);
   		return bean;
	}
	
	/**
	 * 设置优先条件
	 * @return
	 * @throws Exception
	 */
	public static setConditionLevelBean initSetConditionLevelBean(Integer agentId,Integer supplierId) throws Exception
	{
		setConditionLevelBean bean=new setConditionLevelBean();
        bean.setAgentId(agentId);
        bean.setSupplierId(supplierId); 
	    List<condition> lst=new ArrayList<condition>();
	    condition con=new condition();
	    con.setConditionType(5);
	    con.setConditionLevel(8);
	    lst.add(con);
   		bean.setList(lst);
   		return bean;
	}
	
	public static setConditionLevelCall setConditionLevel(setConditionLevelBean bean) throws Exception
	{
		setConditionLevelCall call=new setConditionLevelCall();
		call.setData(bean);
		call.callService();
		return call;
	}
	
	public static setBizConfigBean initSetBizConfig()
	{
		setBizConfigBean bean=new setBizConfigBean();
        Integer bizId=Integer.parseInt(TestDataManager.getRandomNum(5));
        String key="key_"+TestDataManager.getRandomNum(5);
        String value="value"+TestDataManager.getRandomNum(5);
		Map<String,String> map=new HashedMap();
		map.put(key, value);
		//map.put(key+"_1", value+"_1");
		bean.setBizId(bizId);
		bean.setBizConfigMap(map);
		return bean;
	}
	/**
	 * 初始化一个自定义配置
	 * @param key
	 * @param value
	 * @return
	 */
	public static setBizConfigBean initSetBizConfig(String key,String value)
	{
		setBizConfigBean bean=new setBizConfigBean();
        Integer bizId=Integer.parseInt(TestDataManager.getRandomNum(5));
		Map<String,String> map=new HashedMap();
		map.put(key, value);
		bean.setBizId(bizId);
		bean.setBizConfigMap(map);
		return bean;
	}
	public static setBizConfigCall setBizConfig(setBizConfigBean bean) throws ClientProtocolException, IOException
	{
		setBizConfigCall call=new setBizConfigCall();
		call.setData(bean);
		call.callService();	
		return call;
	}
	
	
	
	public static setAgentMarkupConfigBean initSetAgentMarkupConfigBean(Integer... mchId) throws Exception
	{
		Integer mchId_now=0;
		setAgentMarkupConfigBean bean=new setAgentMarkupConfigBean();
		
		if(mchId.length>0) mchId_now=mchId[0];
		else mchId_now=GodmchManageCallService.CreateSellerMch();
		Thread.sleep(5000);
        //查询代理类型
		Map<String, Object> map = new HashMap<>();
		map.put("mchId", mchId_now);
		List<agent_type> list = agentTypeWapper.selectby(map);
		
		List<PercentageItem> items=new ArrayList();
		PercentageItem item=new PercentageItem();
		item.setAgentTypeId(list.get(0).getAgentType());
		item.setPercentage(new BigDecimal(10));
		items.add(item);
		bean.setMchId(mchId_now);
		bean.setPercentageList(items);
		bean.setDecimalType(1);
		bean.setRefreshProduct(false);
		return bean;
	}
	
	public static setAgentMarkupConfigCall initSetAgentMarkupConfigCall(setAgentMarkupConfigBean bean) throws ClientProtocolException, IOException
	{
		setAgentMarkupConfigCall call=new setAgentMarkupConfigCall();
		call.setData(bean);
		call.callService();	
		return call;
	}
	
	
	/**
	 * 设置代理价按条件加价规则bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 * @throws Exception 
	 */
	public static setAgentConditionMarkupConfigBean initSetAgentConditionMarkupConfig(Integer... mchId) throws Exception
	{
		Integer mchId_now=0;
		setAgentConditionMarkupConfigBean bean=new setAgentConditionMarkupConfigBean();
		if(mchId.length>0) mchId_now=mchId[0];
		else mchId_now=GodmchManageCallService.CreateSellerMch();
		Logger.comment("####################  1");
		Thread.sleep(5000);
        //查询代理类型
		Map<String, Object> map = new HashMap<>();
		map.put("mchId", mchId_now);
		List<agent_type> list = agentTypeWapper.selectby(map);
		Logger.comment("####################  2");
		
		List<PercentageItem> items=new ArrayList();
		PercentageItem item=new PercentageItem();
		item.setAgentTypeId(list.get(0).getAgentType());
		Logger.comment("####################  3");
		
		item.setPercentage(new BigDecimal(10));
		items.add(item);
		bean.setMchId(mchId_now);
		bean.setPercentageList(items);
		bean.setDecimalType(1);
		bean.setRefreshProduct(false);
	    //品牌
	    bean.setBrandList(Lists.newArrayList(Integer.parseInt(TestDataManager.getRandomNum(5))));
		Logger.comment("####################  4");
	    return bean;
	}
	
	/**
	 * 设置代理价按条件加价规则bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 * @throws Exception 
	 */
	public static setAgentConditionMarkupConfigBean initSetAgentConditionMarkupConfig(Integer AgentId,AddAgentProductBean addAgentProductBean) throws Exception
	{
		Integer MchId=addAgentProductBean.getUserId();
		setAgentConditionMarkupConfigBean bean=new setAgentConditionMarkupConfigBean();
		//查询代理类型
		Map<String, Object> map = new HashMap<>();
		map.put("parentMchId", MchId);
		map.put("mchId", AgentId);
		mch_relation mch_relation = new mch_relationWapper().selectby(map).get(0);
				
				
		List<PercentageItem> items=new ArrayList();
		PercentageItem item=new PercentageItem();
		item.setAgentTypeId(mch_relation.getAgentType());
		item.setPercentage(new BigDecimal(10));
		items.add(item);
		bean.setMchId(MchId);
		bean.setPercentageList(items);
		bean.setDecimalType(3);
		bean.setRefreshProduct(true);
		
	    bean.setBrandList(Arrays.asList(addAgentProductBean.getBrandId()));
//	    bean.setCategoryList(Arrays.asList(addAgentProductBean.getCategoryId()));
	    return bean;
	}
	
	
	/**
	 * 设置代理价按条件加价规则bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 * @throws Exception 
	 */
	public static setAgentConditionMarkupConfigBean initSetAgentConditionMarkupConfig(Integer Agent,Integer Agent1) throws Exception
	{
		setAgentConditionMarkupConfigBean bean=new setAgentConditionMarkupConfigBean();
		//查询代理类型
		Map<String, Object> map = new HashMap<>();
		map.put("parentMchId", Agent);
		map.put("mchId", Agent1);
		mch_relation mch_relation = new mch_relationWapper().selectby(map).get(0);
				
		List<PercentageItem> items=new ArrayList();
		PercentageItem item=new PercentageItem();
		item.setAgentTypeId(mch_relation.getAgentType());
		item.setPercentage(new BigDecimal(10));
		items.add(item);
		bean.setMchId(Agent);
		bean.setPercentageList(items);
		bean.setDecimalType(3);
		bean.setRefreshProduct(true);
		
	    bean.setBrandList(Arrays.asList(21488));
//	    bean.setCategoryList(Arrays.asList(addAgentProductBean.getCategoryId()));
	    return bean;
	}
	
	
	
	public static setAgentConditionMarkupConfigCall setAgentConditionMarkupConfigCall(setAgentConditionMarkupConfigBean bean) throws ClientProtocolException, IOException
	{
		setAgentConditionMarkupConfigCall call=new setAgentConditionMarkupConfigCall();
		call.setData(bean);
		call.callService();	
		return call;
	}
	
	
	
	
	/**
	 * 设置代理优先条件
	 * @return
	 * @throws Exception
	 */
	public static setAgentConditionLevelBean initSetAgentConditionLevelBean(Integer mchId) throws Exception
	{
		setAgentConditionLevelBean bean=new setAgentConditionLevelBean();
        bean.setMchId(mchId); 
	    List<condition> lst=new ArrayList<condition>();
	    condition con=new condition();
	    con.setConditionType(5);
	    con.setConditionLevel(8);
	    lst.add(con);
   		bean.setList(lst);
   		return bean;
	}
	
	public static setAgentConditionLevelCall setAgentConditionLevel(setAgentConditionLevelBean bean) throws Exception
	{
		setAgentConditionLevelCall call=new setAgentConditionLevelCall();
		call.setData(bean);
		call.callService();
		return call;
	}
	
	
	
	/**
	 * 修改代理自动加价bean
	 * @param agentId
	 * @param supplierId
	 * @return
	 * @throws InterruptedException 
	 */
	public static updateAgentConditionMarkupConfigBean initUpdateAgentConditionMarkupConfig(Integer mchId,Integer markupId,setAgentConditionMarkupConfigBean setBean) throws InterruptedException
	{
		updateAgentConditionMarkupConfigBean bean=new updateAgentConditionMarkupConfigBean();
		bean.setMchId(mchId);
		bean.setMarkupId(markupId);
	    
		bean.setBrandList(setBean.getBrandList());
		bean.setCategoryList(setBean.getCategoryList());
		bean.setDepotList(setBean.getDepotList());
		 //查询代理类型
		Map<String, Object> map = new HashMap<>();
		map.put("mchId", mchId);
		List<agent_type> list = agentTypeWapper.selectby(map);
		
		List<PercentageItem> items=new ArrayList();
		PercentageItem item=new PercentageItem();
		item.setAgentTypeId(list.get(0).getAgentType());
		item.setPercentage(new BigDecimal(10));
		items.add(item);
		bean.setMchId(mchId);
		bean.setPercentageList(items);
		bean.setDecimalType(1);
		bean.setRefreshProduct(false);
	    //品牌
	    bean.setBrandList(Lists.newArrayList(Integer.parseInt(TestDataManager.getRandomNum(5))));
	    return bean;
	}
	
	
	public static getChannelPicCall getChannelPic(Integer mchId) throws ClientProtocolException, IOException
	{
		getChannelPicBean bean=new getChannelPicBean();
		getChannelPicCall call=new getChannelPicCall();
		bean.setMchId(mchId);
		call.setData(bean);
		call.callService();
		return call;
	}
	//获取邀请分销机构分享图片
	public static getInviteDistributorOrganizationPicCall getInviteDistributorOrganizationPic(Integer mchId) throws ClientProtocolException, IOException
	{
		getInviteDistributorOrganizationPicBean bean=new getInviteDistributorOrganizationPicBean();
		getInviteDistributorOrganizationPicCall call=new getInviteDistributorOrganizationPicCall();
		bean.setMchId(mchId);
		call.setData(bean);
		call.callService();
		return call;
	}
	/**
	 * 独立云绑定商户关系
	 * @param mchId
	 * @param code
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static bindRelationBean bindRelation(Integer mchId,String code) throws ClientProtocolException, IOException
	{
		bindRelationBean bean=new bindRelationBean();
		bindRelationCall call=new bindRelationCall();
		bean.setMchId(mchId);
		bean.setCode(code);
		call.setData(bean);
		call.callService();
		return bean;
	}
	/**
	 * 获取代理推广商邀请图片
	 * @param agentId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static getAgentPromotePicCall getAgentPromotePic(Integer agentId) throws ClientProtocolException, IOException
	{
		getAgentPromotePicBean bean=new getAgentPromotePicBean();
		getAgentPromotePicCall call=new getAgentPromotePicCall();
        bean.setMchId(agentId);
		call.setData(bean);
		call.callService();	
		return call;
	}
	
	
	public static setPointConfigBean setPointConfig(Integer... mchId) throws ClientProtocolException, IOException, JSONException
	{
		Integer new_mchId=0;
		if(mchId.length>0) new_mchId=mchId[0];
		else{
		    createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
	        createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
	        new_mchId=createIndepMchCall.getmchId();
		}
		setPointConfigBean bean=new setPointConfigBean();
		setPointConfigCall call=new setPointConfigCall();
		
        List<PointConfig> list=new ArrayList<>();
        PointConfig config=new PointConfig();
        config.setPointType(100);
        config.setPoint(20);
        list.add(config);
        
//        config=new PointConfig();
//        config.setPointType(101);
//        config.setPoint(30);
//        list.add(config);
        
        bean.setMchId(new_mchId);
        bean.setEnabled(true);
        bean.setPointConfigList(list);
		call.setData(bean);
		call.callService();		
		return bean;
	}
	// private static int produceTaskSleepTime = 5;
	// private static int consumeTaskSleepTime = 5000;
	// private static int produceTaskMaxNumber = 20; //定义最大添加10个线程到线程池中

	
	public static addPointBean addPoint(Integer... agentId) throws ClientProtocolException, IOException, JSONException, InterruptedException
	{
		Integer agentId_now=0;
		if(agentId.length==0)
		{
			Integer mchId=agent_promote_mchId;
	        //开启商户积分
	        setBizConfigBean configBean=new setBizConfigBean();
	        configBean.setBizId(mchId);
	    	Map<String,String> map=new HashedMap();
			map.put("enable_point", "1");
			configBean.setBizConfigMap(map);
	        GodmchManageCallService.setBizConfig(configBean);
	        agentId_now= GodmchManageCallService.applyAndapproveAgent(mchId).getAgentId();
		}
		else
		{
			 agentId_now=agentId[0];
		}
	    //point_change_config
	    GodmchManageCallService.setPointConfig(agentId_now);
        
		addPointBean bean=new addPointBean();
		addPointCall call=new addPointCall();
        bean.setUserId(agentId_now);
        bean.setPointType(101);
		call.setData(bean);
		call.callService();	
		return bean;
	}
	
	
	/**
	 * 公有云注册 bean
	 * @return
	 */
	public static registerBean initRegister(){
		registerBean bean=new registerBean();
		bean.setCountry("USA");
		bean.setMobile(TestDataManager.getPhoneNum());
		bean.setPassword("www123");
		bean.setAppSource(60);// 代购神器买家端小程序
		bean.setTerminalSource(0);// 其他 default
		bean.setAppKey("appsqseller");
		return bean;
	}
	/**
	 * 公有云注册 call
	 * @param bean
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static registerCall registerCall(registerBean bean) throws ClientProtocolException, IOException{
		registerCall call=new registerCall();
		call.setData(bean);
		call.callService();	
		return call;
	}
	
	public static authShopDesignBean authShopDesign(Integer mchId,Integer parentMchId) throws ClientProtocolException, IOException
	{
		authShopDesignBean bean=new authShopDesignBean();
		authShopDesignCall call=new authShopDesignCall();
		bean.setMchId(mchId);
		bean.setParentMchId(parentMchId);
		bean.setAppKey("appKey_"+TestDataManager.getRandomNum(5));
		call.setData(bean);
		call.callService();	
		return bean;
	}
	
	public static cancelAuthShopDesignBean cancelAuthShopDesign(Integer mchId,Integer parentMchId) throws ClientProtocolException, IOException
	{
		cancelAuthShopDesignBean bean=new cancelAuthShopDesignBean();
		cancelAuthShopDesignCall call=new cancelAuthShopDesignCall();
		bean.setMchId(mchId);
		bean.setParentMchId(parentMchId);
		call.setData(bean);
		call.callService();	
		return bean;
	}
	
	public static getInviteCpsPicCall getInviteCpsPic(Integer mchId)
			throws ClientProtocolException, IOException, JSONException {
		getInviteCpsPicBean bean = new getInviteCpsPicBean();
		getInviteCpsPicCall call = new getInviteCpsPicCall();

		bean.setMchId(mchId);
		call.setData(bean);
		call.callService();
		return call;
	}
	
	public static BigDecimal getEffectExchangeRate(Long merchantId)
			throws Exception {

		GetEffectExchangeRateBean getEffectExchangeRateBean = new GetEffectExchangeRateBean();
		GetEffectExchangeRateCall getEffectExchangeRateCall = new GetEffectExchangeRateCall();

		getEffectExchangeRateBean.setExchangeCurrency("MOP");
		getEffectExchangeRateBean.setMerchantId(merchantId);
		getEffectExchangeRateBean.setSrcCurrency("CNY");

		getEffectExchangeRateCall.setData(getEffectExchangeRateBean);
		getEffectExchangeRateCall.callService();

		return new BigDecimal(getEffectExchangeRateCall.getExchangeRate()
				.toString());
	}
	
	public static void main(String[] args) throws Exception {
	//	Integer mchId = GodmchManageCallService.CreateGodMch();
//		Integer agenttype=GodmchManageCallService.getAgentType(mchId, 1);
//		Integer agent_mchId = GodmchManageCallService.getAgentMchId(mchId, agenttype);
//		createDepotBean bean=GodmchManageCallService.createDepot(mchId);
//        List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());
//		AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "", true);
//		addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
//		String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
//		setConditionMarkupConfigBean setConditionMarkupConfigBean = GodmchManageCallService.initDefSetConditionMarkupConfig(agent_mchId, mchId, 1, addAgentProductBean, 1);
//		GodmchManageCallService.SetConditionMarkupConfigCall(setConditionMarkupConfigBean);
		
//		GodmchManageCallService.InitlistgentTypeBean(mchId);
//		Integer mchId = GodmchManageCallService.CreateAllMsgSellerMch().getMchId();

//		 GodmchManageCallService.createMchForStore(createCall.getmchId());
		// createmchBean
		// bean=GodmchManageCallService.InitcreatemchBeanForChannel();//500009705
		// GodmchManageCallService.createmchCallForAgent(bean);
		// GodmchManageCallService.SetVip(bean.getMchId());
		//
		// List<createmchBean>
		// createmchList=GodmchManageCallService.InitcreatemchBeanForAgent(AgentUsers.vipAgentUserId1);
		// GodmchManageCallService.createmchCallForAgent(createmchList.toArray(new
		// createmchBean[0]));

		// GodmchManageCallService.getProviderById();

		// InitcreatemchBeanForAgent(500002490,userId1);

		// UserCreateBean
		// usercreateBean1=DGUserCallService.initUsercreateBean();
		// UserCreateBean
		// usercreateBean2=DGUserCallService.initUsercreateBean();
		// UserCreateBean
		// usercreateBean3=DGUserCallService.initUsercreateBean();
		// int userId1=DGUserCallService.UserCreateCall(usercreateBean1);
		// int userId2=DGUserCallService.UserCreateCall(usercreateBean2);
		// int userId3=DGUserCallService.UserCreateCall(usercreateBean3);
		//
		// int[] agentId={userId1,userId2,userId3};
		// GodmchManageCallService service=new GodmchManageCallService();
		// List<createmchBean>
		// createmchList=service.InitcreatemchBeanForAgent(500001293,agentId) ;
		//
		// service.createmchCallForAgent(createmchList.toArray(new
		// createmchBean[createmchList.size()]));
		// System.out.println("ok");
		// GodmchManageCallService.CreateagentCall(500001426, "郑旭用");
		// //渠道
		//// createmchBean
		// createmchBean_channel=GodmchManageCallService.InitcreatemchBeanForChannel(186);
		//// createmchCall
		// createmchCall_channel=GodmchManageCallService.createmchCallForChannel(createmchBean_channel);
		// int mchId=500001293;
		//// //渠道1
		// createBean bean=new createBean();
		// createCall createcall=new createCall();
		//// bean.setMchId(mchId);
		//// bean.setCodeRole(1);
		// //创建代理类型1
		// createagentBean createagentBean1=InitcreateagentBean(mchId);
		// createagentBean1.setTitle("南京代理");
		// createagentCall createagentcall=createagentCall(createagentBean1);
		////// //创建代理类型2
		////// createagentBean createagentBean2=InitcreateagentBean(mchId);
		////// createagentBean2.setTitle("北京代理");
		////// createagentCall
		// createagentcall2=createagentCall(createagentBean2);
		////
		// Map<String,Object> map=new HashMap();
		// map.put("mchId", mchId);
		// List<agent_type> list=agentTypeWapper.selectby(map);
		// bean.setRoleType(list.get(0).getAgentType());//代理类型(如：北京代理，上海代理)
		// bean.setIsPermanently(true);
		// createcall.setData(false,bean);
		// createcall.callService();
		//
		//// createCall createcal2=new createCall();
		//// bean.setRoleType(list.get(1).getAgentType());//代理类型(如：北京代理，上海代理)
		//// createcal2.setData(false,bean);
		//// createcal2.callService();
		//
		//
		// //代理1
		// UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
		// int userId1=DGUserCallService.UserCreateCall(usercreateBean);
		//// UserCreateBean
		// usercreateBean2=DGUserCallService.initUsercreateBean();
		//// int userId2=DGUserCallService.UserCreateCall(usercreateBean2);
		////
		// createmchBean createmchbean=new createmchBean();
		//// createmchbean.setMchId(userId1);
		//// createmchbean.setCode(createcall.getCode());
		// createmchbean.setCountry("USA");
		// createmchCall createmchcall=new createmchCall();
		//// createmchcall.setData(false,createmchbean);
		//// createmchcall.callService();
		// //代理2
		// createmchbean.setMchId(userId1);
		// createmchbean.setCode("74");
		// createmchcall.setData(false,createmchbean);
		// createmchcall.callService();

		// testDemo

		//
		// //构造一个线程池
		// ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 4, 3,
		// TimeUnit. SECONDS, new ArrayBlockingQueue<Runnable>(3),
		// new ThreadPoolExecutor.DiscardOldestPolicy());
		// for( int i=1; i<= produceTaskMaxNumber;i++){
		// try {
		// //一个任务，并将其加入到线程池
		// String work= "work@ " + i;
		// System. out.println( "put ：" +work);
		// threadPool.execute( new ThreadPoolTask(work));
		// //便于观察，等待一段时间
		// Thread. sleep(produceTaskSleepTime);
		// } catch (Exception e) {
		// e.printStackTrace();
		// }
		// }
		//
		//
		//
		// }
		//
		//
		// /**
		// * 线程池执行的任务
		// * @author zhu
		// */
		// public static class ThreadPoolTask implements Runnable,Serializable{
		// private static final long serialVersionUID = 0;
		// //保存任务所需要的数据
		// private Object threadPoolTaskData;
		// ThreadPoolTask(Object works){
		// this. threadPoolTaskData =works;
		// }
		// public void run(){
		// //处理一个任务，这里的处理方式太简单了，仅仅是一个打印语句
		// System. out.println( "start------"+threadPoolTaskData );
		// try {
		// //便于观察，等待一段时间
		// Thread. sleep(consumeTaskSleepTime);
		// } catch (Exception e) {
		// e.printStackTrace();
		// }
		// threadPoolTaskData = null;
		// }
		// public Object getTask(){
		// return this. threadPoolTaskData;
		// }

//		String[] cards = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
//		int len = cards.length;
//		java.util.Random ran = new java.util.Random();
//		for (int i = 0; i < 10; i++) {
//			int temp = ran.nextInt(len);
//			String c = cards[temp];
//			cards[temp] = cards[0];
//			cards[0] = c;
//		}
		
		GodmchManageCallService.getEffectExchangeRate(502665591L);
//		int a=-1;
//		int b=2;
//		if(a>0|b>0)
//		{
//			System.out.println("####  true");
//		}
//		else{
//			System.out.println("####  false");
//		}
		
	}
}
